Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Intro Black Friday Offer for a lifetime*

[SOLVED] CB Code Field

  • Abmago
  • Abmago
  • OFFLINE
  • Posts: 47
  • Thanks: 6
  • Karma: 0
4 years 7 months ago - 4 years 7 months ago #317654 by Abmago
[SOLVED] CB Code Field was created by Abmago
This is a question about the add-on 'CB Code Field'. It is not clear to me how I can design a good working Code Drop Down (Single Select). I am no expert in PHP code, but with some good examples I can make simple things. The dropdown function seems important to me, but I experience difficulties in writing the right code.

In have made a field called CB_kingetal where the user fills in a number between 0 and 261. In one of the interpretation the values 1, 21 or 41, 61, have the same outcome namely 'IMIX'. 2, 22, 42, etc. have the outcome 'IK'.

I want an automatic 'choice' in the Single Select Dropdown menu. The first value in the dropdown, namely IMIX, shoud be chosen automatically for users with CB_kingetal = 1, or 21 etc. From a logical point of view, the first value of the dropdown should become true if CB_field is 1 or 21, etc. What PHP code do I need to make this automation work?

I can't find good examples to find my own solution and need some clues.
Last edit: 4 years 7 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48551
  • Thanks: 8291
  • Karma: 1445
4 years 7 months ago #317659 by krileon
Replied by krileon on topic CB Code Field
The Code Select field simply takes the resulting array and turns it into options in the dropdown. It does not determine what is selected or not. I suppose it technically can if the field is set to be required so it has no blank value and the user hasn't selected something yet then the first option available technically will be selected on edit display, but the value won't be stored in the database for display unless the profile is saved with it selected.

What is the purpose of the select field exactly? Do users need to actually be selecting something or is it just for displaying the calculated result of CB_kingetal? You may not need a code select at all depending on what you're trying to do exactly.


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.

  • Abmago
  • Abmago
  • OFFLINE
  • Posts: 47
  • Thanks: 6
  • Karma: 0
4 years 7 months ago #317681 by Abmago
Replied by Abmago on topic CB Code Field
I use the field type 'custom HTML' to show the results. I use the following code: [cb:if cb_kingetal="1" or [cb:if cb_kingetal="21"]IMIX[/cb:if]. This works fine!

I can show the right results (IMIX) in the profile, even in combination with a hyperlink to the Joomla article with information about IMIX.

So far so good.

But I also want to make it possible to search for IMIX in 'list view'. IMIX is 1 of 20 options, which I want to offer in dropdown menu. But since selection of IMIX is automated by 'custom HTML' I have no filled drop down menu anymore. How can I fill it automatically?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48551
  • Thanks: 8291
  • Karma: 1445
4 years 7 months ago #317691 by krileon
Replied by krileon on topic CB Code Field
Seams like it'd be best to just allow searching on cb_kingetal. There's not a way to automate filling like what you're wanting without duplicating stored data using CB Auto Actions for example.


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.

  • Abmago
  • Abmago
  • OFFLINE
  • Posts: 47
  • Thanks: 6
  • Karma: 0
4 years 7 months ago #317705 by Abmago
Replied by Abmago on topic CB Code Field
Yess! This was perfect suggestion! With CB Auto Action I am indeed able to fill the dropdown menu automatically after registration! And this only works for field type code drop down (so not for 'normal' drop menus). This field type is only available in CB Code Field. So for my solution I needed to combine features of CB Code and CB Auto Action.
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum