help with developing a code

12 years 4 months ago - 12 years 4 months ago #184223 by amir00251
help with developing a code was created by amir00251
Hi, I am working to see if I can add some functionality to be used according to CB in other component and I used below code:

<?php
global $_CB_framework;
$fieldName = "cb_test";
echo "$fieldName";
$cbUser = &CBuser::getInstance( $_CB_framework->displayedUser() );
$field = $cbUser->getField( $fieldName );
echo "$field";
if ($field == "London" ) {
...
}

What I am trying to achieve is to get the value selected by user for cb_test field.

The cb_test is a multi select dropdown field.
In the above the first echo does output the name of the field correct.
But the issue is the second echo does not output anything and it is suppose to output the value of the cb_test field.

Just to add that cb_test does definitely has value (I have tried both choosing only a single value or multi values) still output is none.

Now my first question is that is there something wrong in the code?

The second question is that for a multi-select dropdown (which values of the field can be more than one) is above code correct or it should be changed? Ideally I want to have

if ($field1 == "London" or $field2 == "London" or .....) in the end conditional where field1, field2, ... are the user selections in dropdown field cb_test.

Please Log in to join the conversation.

12 years 4 months ago #184267 by krileon
Replied by krileon on topic Re: help with developing a code
See tutorials within my signature regarding API usage or review the API documentation in the Free downloads section. We do not assist in coding, sorry. You're also welcome to contract out to sites like joomlancers. If new to PHP I highly recommend the below tutorials.

www.w3schools.com/php/default.asp


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.183 seconds

Facebook Twitter LinkedIn