Jump to content

Converting Checkbox Set Values To A List


SeanJ66

Recommended Posts

Posted

Hi all

I'm currently building a database and setting up the fields. Right now the values from a checkbox set field get displayed on the same line on the display template, separated by commas. How do I get each value from the checkbox set to be displayed on one line or rather how could I give each value a tag so I can manipulate it with css accordingly?

Posted

If you edit the field in the AdminCP, on the second tab there are options to provide custom listing and display page formats. You would leverage this to customize how the value is output.

Posted
18 hours ago, bfarber said:

If you edit the field in the AdminCP, on the second tab there are options to provide custom listing and display page formats. You would leverage this to customize how the value is output.

Thanks @bfarber have been using that and am aware of that. When I set the Display View Format to custom and use the {$value} tag it outputs all the checkbox set values in a string separated by commas. I want each value to be either placed into a bullet list or I just want each value to be given a span tag so I can style it into a list. Is there a relatively simple way of doing this or does it require complex coding?

Posted

I've not gone in and played around with this, but something like this should probably work:

{{if $results = explode( ',', $value )}}
	{{foreach $results as $item}}
		<li>{expression="trim($item)"}</li>
	{{endforeach}}
{{endif}}

 

  • 2 weeks later...
Posted
On 2/28/2020 at 2:48 PM, bfarber said:

I've not gone in and played around with this, but something like this should probably work:


{{if $results = explode( ',', $value )}}
	{{foreach $results as $item}}
		<li>{expression="trim($item)"}</li>
	{{endforeach}}
{{endif}}

 

Thanks a million @bfarber that did the trick. Just needed to add the <ul> tags

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...