[SOLVED] MultiCheckbox replace value with image

8 years 1 week ago - 7 years 1 month ago #280628 by solferry
Dear,

I found an old topic pointing to a tutorial, but the link was broken.. therefor yet the same question.

I have the options for people to select some values within a multicheckbox.
I am not sure if I am going to use the multicheckbox yet or multiple single checkboxes.. but I suppose the way of working would be more or less the same.

What I would like, is when my user selects some options the selected options are displayed on his/her profile by a replaced image.

So:
-if selected (value1){ display: image1}
-if selected (value2){ display: image2}
etc

As users can select multiple options... it shouldn't be 1 if..else but just multiple if statements.

Thanks in advance.

Please Log in to join the conversation.

8 years 1 week ago #280633 by krileon
Replied by krileon on topic MultiCheckbox replace value with image
You need to use IF substitutions in the fields Profile Value Layout parameter found under Parameters > Layouts while editing your field in CB > Field Management. Example as follows.

[cb:if cb_myfield="value_1"]<img src="images/myfield/value_1.png" alt="value_1" />[/cb:if]
[cb:if cb_myfield="value_2"]<img src="images/myfield/value_2.png" alt="value_2" />[/cb:if]
[cb:if cb_myfield="value_3"]<img src="images/myfield/value_3.png" alt="value_3" />[/cb:if]
[cb:if cb_myfield="value_4"]<img src="images/myfield/value_4.png" alt="value_4" />[/cb:if]

Please see the below tutorial for further substitution usage information.

www.joomlapolis.com/support/tutorials/107-use-cases/18353-using-substitutions-throughout-cb


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.

8 years 1 week ago #280645 by solferry
Replied by solferry on topic MultiCheckbox replace value with image
Thanks, will check that one!

Please Log in to join the conversation.

7 years 1 month ago #292430 by Aquinum
Replied by Aquinum on topic MultiCheckbox replace value with image
Hello, I did as you said and it does not work :(

I put this substitution for displaying values in list of users and profile's vue but nothing appears. I want the flags instead of text.
(my PHP version is 7.1.1, Joomla 3.6.5 and version of CB is 2.1.2)

<!--[value]-->
[cb:if cb_lang="fr"]<img src="images/lang/fr.gif" alt="Français" />[/cb:if]
[cb:if cb_lang="en"]<img src="images/lang/en.gif" alt="Anglais" />[/cb:if]
[cb:if cb_lang="de"]<img src="images/lang/de.gif" alt="Allemand" />[/cb:if]
[cb:if cb_lang="it"]<img src="images/lang/it.gif" alt="Italien" />[/cb:if]
[cb:if cb_lang="pt"]<img src="images/lang/pt.gif" alt="Portugais" />[/cb:if]
[cb:if cb_lang="es"]<img src="images/lang/es.gif" alt="Espagnol" />[/cb:if]
[cb:if cb_lang="ch"]<img src="images/lang/zh.gif" alt="Chinois" />[/cb:if]
[cb:if cb_lang="gr"]<img src="images/lang/el.gif" alt="Grec" />[/cb:if]
[cb:if cb_lang="ar"]<img src="images/lang/ar.gif" alt="Arabe" />[/cb:if]
[cb:if cb_lang="se"]<img src="images/lang/sv.gif" alt="Suédois" />[/cb:if]
[cb:if cb_lang="pl"]<img src="images/lang/pl.gif" alt="Polonais" />[/cb:if]
[cb:if cb_lang="ru"]<img src="images/lang/ru.gif" alt="Russe" />[/cb:if]
[cb:if cb_lang="ne"]<img src="images/lang/nl.gif" alt="Néerlandais" />[/cb:if]
[cb:if cb_lang="co"]<img src="images/lang/ko.gif" alt="Coréen" />[/cb:if]
[cb:if cb_lang="ja"]<img src="images/lang/ja.gif" alt="Japonais" />[/cb:if]
[cb:if cb_lang="ukr"]<img src="images/lang/uk.gif" alt="Ukrainien" />[/cb:if]
[cb:if cb_lang="ro"]<img src="images/lang/ro.gif" alt="Roumain" />[/cb:if]

Attachments:

Please Log in to join the conversation.

7 years 1 month ago #292436 by krileon
Replied by krileon on topic MultiCheckbox replace value with image
If your field is a multicheckbox or multiselect then that won't work unless they only have 1 language selected. Multicheckbox and multiselect fieldtypes store their values as VALUE_1|*|VALUE_2|*|VALUE_3|*|etc.. so you need to use the below to condition for them.

FROM:
[cb:if cb_lang="fr"]<img src="images/lang/fr.gif" alt="Français" />[/cb:if]
TO:
[cb:if cb_lang=~"/fr/"]<img src="images/lang/fr.gif" alt="Français" />[/cb:if]

This uses a REGEXP operator as documented in the below tutorial so it can do an inline match.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


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.
The following user(s) said Thank You: Aquinum

Please Log in to join the conversation.

7 years 1 month ago #292441 by Aquinum
Replied by Aquinum on topic MultiCheckbox replace value with image
Ahhhhhh ! Great ! Thank you so much, you saved my life, I can see my little flags now ;)
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.174 seconds

Facebook Twitter LinkedIn