开发者

How do you concatenate two variables for the text of a select.genericlist

in this select.generic list I am wanting to concatenate two variables/fields for the "text" of this list. It is a functioning list.

<?php echo JHtml::_('select.genericlist',  $this->assets, 'id', 'class="inputbox"      onchange="document.location.href = this.value"', 'link',  'serialnumber' , $this->asset->link);?>

Where 'serialnumber' is the field used for the text of the list, I am trying to get 'model' AND 'serialnumber' so that it displays "Model: serialnumber" in the select list.

Everything i have found for concatenation does not work, and seems to just make a string 'model:serialnumber' which is a non-existant field开发者_运维问答.

using $model . $serialnumber is a no go as well, though using just one variable works fine.

Thanks for the help!


Simplest thing would be you do a concat at the db level. So when generating $this->assets you put something like this in the query:

SELECT bla1, bla2, CONCAT('Model: ', bla3) AS text ...

or

SELECT bla1, bla2, CONCAT(model, ': ', serialnumber) AS text ...

if model is a db field.


Taking what Mike said I found where I needed to make the change to the query in the category model of my component. I wasted a lot of time thinking it had to be in the asset model:

$query->select($this->getState('list.select', 'a.id, a.name, CONCAT(a.model,\': \', a.serialnumber)AS modelserialnumber, ...
    $query->from('`#__asset_details` AS a');

Thanks Mike for your help!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜