Get Cb fields in template

7 years 8 months ago #285837 by fabioweb90
Get Cb fields in template was created by fabioweb90
Hello!
i'm reading this doc: www.joomlapolis.com/documentation/18361-obtaining-field-values-through-getfields-api
$cbUser =& CBuser::getInstance( $user->id );
 
if ( ! $cbUser ) {
 $cbUser =& CBuser::getInstance( null );
}

$city= $cbUser->getField( 'cb_city', null, 'html', 'none', 'list' );
echo $city;

In this way the code above should show the city field in the page?

Regrads

Please Log in to join the conversation.

7 years 8 months ago #285839 by krileon
Replied by krileon on topic Get Cb fields in template
Assuming $user exists and the id isn't 0 (guest), yes that would output the userlist view for your cb_city field. Is there a reason you need to hardcode this into a template? I highly suggest just adding a new module position to your template and output a CB Content Module instead. The shorthand code for your usage is as follows though.

echo CBuser::getInstance( $user->id, false )->getField( 'cb_city', null, 'html', 'none', 'list' );


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
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 CST to 4:00 PM CST. 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.

Please Log in to join the conversation.

7 years 8 months ago #285910 by fabioweb90
Replied by fabioweb90 on topic Get Cb fields in template
Thank you :)
i thought this solution because in a previous topic you said me that there isn't integration with virtuemart. and with this method i hope to display cb_fields in cart virtuemart page..

Regards

Please Log in to join the conversation.

7 years 7 months ago - 7 years 7 months ago #285943 by krileon
Replied by krileon on topic Get Cb fields in template
If you can assign modules to the virtuemart cart page I highly recommend just using CB Content Module and substitutions so you won't have to maintain any code.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
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 CST to 4:00 PM CST. 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.

Please Log in to join the conversation.

7 years 7 months ago #286020 by fabioweb90
Replied by fabioweb90 on topic Get Cb fields in template
Awesome. In this way if a user will buy a product how will be managed this information? Email Fields, Invoice.. Etc..

Regards

Please Log in to join the conversation.

7 years 7 months ago #286040 by krileon
Replied by krileon on topic Get Cb fields in template
I've no idea. We're not the developers of Virtuemart so I've no idea how it handles any of that. Using CB Content Module would just let you easily display CB fields on Virtuemart pages.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
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 CST to 4:00 PM CST. 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.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.191 seconds

Facebook Twitter LinkedIn