Concat an image URL from existing column data??

Probably a calc element.

Not sure from your description if "users' is the list you are showing, but assuming it is ...

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('avatar')->from('#__comprofiler___avatar')->where('userid = {#__users___id_raw}');
$myDb->setQuery($myQuery);
$avatar = $myDb->loadResult();
if (!empty($avatar)) {
   return = 'images/comprofiles/gallery/' . $avatar;
}
return '/path/to/default/image.png';

NOTE - I can't recall if we handle #__ in placeholders, so you may need to use the actual table prefix. Also I don't know what the 'userid' field in the comprofiler___avatar table is called, so you'll have to change that.

Also note ... as this data doesn't exist in your list, you'll have to set "Calc on save only" to "No" so it calcs it when displaying your list. This will create an overhead on displaying the list, as it involves an extra query for every row being displayed.

To avoid that, you'd either have to manually edit and save every row, to force the calc element to save the data, or you could manually do it in phpMyAdmin (or your mysql client of choice) by running a query to update your list.

Also note, if this really is your J! users list, that's suboptimal, as it means adding a new field to it (the avatar calc).

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top