[SOLVED] Updating fields in database row

4 months 1 week ago #316374 by jimstrong
Hi. I thought it might be better to add this supplemental question here to keep the correspondence together.

I successfully got your query working :-
SELECT `id`, CONCAT( `firstname`, ' ', `lastname` ) AS name
FROM `#__comprofiler`
WHERE `cb_shac_role` LIKE '%Office%' OR `cb_shac_role` LIKE '%Befriender%'

This allows the selection of user2 in the record of user1 and allows its display in a CB List, but what I am trying to do now (and failing) is to use a similar query to display the avatar of user2 in the record of user1 and similarly to display it in a CB List.

Can you point me in the right direction please?

Thanks a lot

4 months 1 week ago #316382 by krileon
You're using a query select field so no that won't be possible since it has no means of passing the selected value through substitutions as nested substitutions are not allowed in normal circumstances. It should be doable with a code field provided by CB Code Field using PHP and getFields API. Example as follows.

return \CBuser::getInstance( (int) '[FIELD_NAME]', false )->getField( 'avatar', null, 'html', 'none', 'list', 0, true );

Replace FIELD_NAME with the name of your field, which should be a user id. It'd be possible with normal substitutions if the user attribute in substitutions supported a field (e.g. user="FIELD_NAME"), but at this time it does not so have added a feature ticket for that.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
Please note I am available Monday - Friday from 8:00 AM EST to 4:00 PM EST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
4 months 1 week ago #316391 by jimstrong
Thanks so much - worked a treat! I was also able to pull in a contact number using the same approach.

The following user(s) said Thank You: krileon
Moderators: beatnantkrileon
Time to create page: 0.449 seconds

Facebook Twitter LinkedIn