[SOLVED] LISE - checkbox group - selected checkbox text

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

[SOLVED] LISE - checkbox group - selected checkbox text

Post by manuel »

Hi all,

Maybe I'm overlooking something but how can I get the text of a selected checkbox option in a checkbox group to show up in the template?

I'm using multiple checkbox groups where some checkboxes have the same text so I need to enter unique values to be able to differentiate.

ex:
Checkbox group 1
Search=SearchGroup1
...

Checbox group 2
Search=SearchGroup2
...

Code below would return the values SearchGroup1 & SearchGroup2

Code: Select all

{foreach from=$fielddef->values item='value'}
  {$value}
{/foreach}
But I can't find how to return the text "Search"

Some extracts from the module with debugging turned on:
- The checkbox options list does still show both text and value:

Code: Select all

[options] => Support=OthSup
Families=OthFam
- The selected checkbox shows only the value of the checkbox option:

Code: Select all

[values] => Array
  (
    [0] => OthSup
  )
I'm thinking about a messy workaround but hope I'm just missing some insight :)

ps: I'm working in the "Search Template" to generate the filter buttons.

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: LISE - checkbox group - selected checkbox text

Post by manuel »

messy workaround:
I changed the checkbox values to no longer contain separate values for text.

ex:
Checkbox group name:
"Something something"

Checkbox group options:
"Something something::The text I want to have appear in the filter button"
"Something something::Some other text I want to have appear"

Now, in the template, I can get the text I want by adding a replace...

Code: Select all

{foreach from=$fielddef->values item='value'}
  {$value|replace:"{$fielddef->name}::":''}
{/foreach}
If there where no repetitions of the same text in the checkbox group options of the various checkbox groups, this issue wouldn't exist as everything would be unique anyway...

The downside for this workaround besides the extra replace is that content editors will see "Something something::The text I want to have appear in the filter button" besides the checkbox in the backend but it's acceptable for me if it does the trick to get the correct text on the filter buttons in the frontend...

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE - checkbox group - selected checkbox text

Post by velden »

Hi Manuel,

Find one approach I could come up with below.

GetOptions is an undocumented method so use at your own discretion.

Code: Select all

{$option_values = $fielddef->GetOptions()}
			<select name="{$actionid}search_{$fielddef->alias}" id="filter_{$fielddef->alias}">
				<option value=''>{$mod->ModLang('all')}</option>
				{foreach from=$fielddef->values item=value}
				<option value="{$value}">{$option_values[$value]}</option>
				{/foreach}
			</select>
Last edited by velden on Wed Apr 03, 2019 6:56 pm, edited 1 time in total.
Reason: Manual -> Manuel :-)
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: LISE - checkbox group - selected checkbox text

Post by manuel »

Oooh, nice one Velden, thanks! :)
I'll just add the URL to this thread in the code should it break with future upgrades but I'll switch to the solution you suggest! (tested and works) :)

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [SOLVED] LISE - checkbox group - selected checkbox text

Post by calguy1000 »

,<cough>
see the smarty plugin {html_options}
</cough>
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: [SOLVED] LISE - checkbox group - selected checkbox text

Post by velden »

calguy1000 wrote:,<cough>
see the smarty plugin {html_options}
</cough>
It should be noted that

a. LISE originally doesn't provide the input for {html_options}
b. The GetOptions() will return ALL options where '$fielddef->values' will be limited to actually relevant values*

*It will not show values which aren't used in any item. Also - though didn't check - that it may be limited by using other filters like categories etc.
Post Reply

Return to “Modules/Add-Ons”