Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi again!

Considering I would be using this code :

Code: Select all
<cms:editable name="my_categories" label="Categories" desc="Check all applicable"
  opt_values='Entertainment=0 | Computers=1 | Sports=2 | Health=3'
  opt_selected = '2'
  type='checkbox'
/>


Is it possible to output "Sports" instead of "2"?

I mean, being able to output the word before the value.
So, output "Sports" in the "Sports=2" value.
Output "Health" in the "Health=3" value.
and so on.

By default, It displays the number after the "...=" (equals symbol).

There's a reason behind it, but I cannot change the numbers of each opt_values in my project.
But I would like to output the "word" of each options somewhere.

Thanks!
Hi Marc,

Can you delete the numbers? If so, it is possible to address values by their names. opt_values="Sports | Computers" etc,
Hi Anton,

No it is not possible for me to delete these numbers.
I have over 100 clonable pages linked to these numbers.

That's why I want to know if it's possible to take the word part only.

If not that's ok. Thanks
Getting labels of checkbox editable is a bit complicated and probably unnecessary.

I assume, the choices exist in admin panel and user is not changing labels of checkboxes (only selects predefined values), only super-admin changes editables. If so, a much simpler check can be used -

Code: Select all

<cms:if my_category = '0' >
    <cms:set cat_name_0 = 'Entertainment' scope='global' />
<cms:else_if my_category = '1' />
    <cms:set cat_name_1 = 'Computers' scope='global' />
<cms:else_if my_category = '2' />
    <cms:set cat_name_2 = 'Sports' scope='global' />
<cms:else_if my_category = '3' />
    <cms:set cat_name_3 = 'Health' scope='global' />
</cms:if>

chosen category: <cms:show my_category /><br>
category_name: <cms:get "cat_name_<cms:show my_category />" />

OR, simpler:

    <cms:set cat_name_0 = 'Entertainment' scope='global' />
    <cms:set cat_name_1 = 'Computers' scope='global' />
    <cms:set cat_name_2 = 'Sports' scope='global' />
    <cms:set cat_name_3 = 'Health' scope='global' />

chosen category: <cms:show my_category /><br>
category_name: <cms:get "cat_name_<cms:show my_category />" />

OR, different


<cms:if my_category = '0' >
    <cms:set cat_name = 'Entertainment' scope='global' />
<cms:else_if my_category = '1' />
    <cms:set cat_name = 'Computers' scope='global' />
<cms:else_if my_category = '2' />
    <cms:set cat_name = 'Sports' scope='global' />
<cms:else_if my_category = '3' />
    <cms:set cat_name = 'Health' scope='global' />
</cms:if>


chosen category: <cms:show my_category /><br>
category_name: <cms:show cat_name />




Is this helpful?
Thanks Anton,
But I finally managed to simply use jQuery to output the content.
Since the content was already visible on the front-end (in a dropdown menu list), I did something like this

$("#DropdownID option:selected").text()

That way, I don't have to re-enter all options, telling CouchCMS what "Sports" is equals to.
Thanks for your time!
pipolamenace wrote: Thanks Anton,
But I finally managed to simply use jQuery to output the content.
Since the content was already visible on the front-end (in a dropdown menu list), I did something like this

$("#DropdownID option:selected").text()

That way, I don't have to re-enter all options, telling CouchCMS what "Sports" is equals to.
Thanks for your time!


Welcome :) And thanks for the trick! If the text is already there, it's wise to use it :D I should go study jQuery.
6 posts Page 1 of 1