Skip to Content Skip to Menu

Code

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
1 year 10 months ago #332447 by krileon
Replied by krileon on topic Code
So cb_menulabelmedical, cb_menulabeldental, and cb_menulabelvision are just text fields? If so the below should work fine.
Code:
return [ 3 => '[cb_menulabelmedical]', 4 => '[cb_menulabeldental]', 5 => '[cb_menulabelvision]' ];

Probably even better to just directly access their user object resulting in the following.
Code:
return [ 3 => $user->getString( 'cb_menulabelmedical', '' ), 4 => $user->getString( 'cb_menulabeldental', '' ), 5 => $user->getString( 'cb_menulabelvision', '' ) ];

The way the array is structured is explained in the parameter description. Below is it again.

[ VALUE => LABEL ]

So with the above 3 is the value. Value is what is stored in the database. The user will never see the value. Label is what the user will see in the dropdown and is what they select. If Label is displaying oddly then whatever you're setting as the label would be doing that.


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 or Create an account to join the conversation.

  • bmeeker
  • bmeeker
  • OFFLINE
  • Posts: 65
  • Thanks: 8
  • Karma: 1
1 year 10 months ago #332450 by bmeeker
Replied by bmeeker on topic Code
That worked perfectly (second option)!
Thanks again!
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

  • bmeeker
  • bmeeker
  • OFFLINE
  • Posts: 65
  • Thanks: 8
  • Karma: 1
1 year 10 months ago #332466 by bmeeker
Replied by bmeeker on topic Code
Kyle - that worked perfectly, but of course, I have one more question:
This restrictpages field allows users to restrict pages with a username and password.

I have another field for each page that can be set to show or not show the page on a website menu. 

For the this restrictpages field, I'd like to only show the pages that are shown and not show a label for the pages that are set to not show.
I'd like to be able to show only the labels for pages set to show and not show the labels for a pages that are set to not show.

I can create if statements, but the result ends up just showing the field's text an not processing the value/label. (see attached PDF for screenshots).

I'm know I'm missing something probably pretty simple, but can't see the forest for the trees.

Thanks again. 
 
Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
1 year 10 months ago - 1 year 10 months ago #332476 by krileon
Replied by krileon on topic Code
You're setting $field03, $field04, and $field05 to a string. You should just be adding new options to an array not trying to set a string like that. Code Select expects an array structure as explained in my previous replies. Simple example as follows.

Code:
$options = []; if ( $user->getBool( 'cb_show1', false ) ) { $options['VALUE_1'] = 'LABEL_1'; } if ( $user->getBool( 'cb_show2', false ) ) { $options['VALUE_2'] = 'LABEL_2'; } if ( $user->getBool( 'cb_show3', false ) ) { $options['VALUE_3'] = 'LABEL_3'; } return $options;


I'm sorry I cannot help you any further with your custom coding needs without a business membership. Simple examples is all I can provide for you.


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.
Last edit: 1 year 10 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • bmeeker
  • bmeeker
  • OFFLINE
  • Posts: 65
  • Thanks: 8
  • Karma: 1
1 year 10 months ago #332480 by bmeeker
Replied by bmeeker on topic Code
That works - I was able to hack your sample code to make it work!
FYI - the first line was missing the closing ; - if anyone wants to use this code example.
$options = [] ;

Thanks again for all your help.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum