Convert textbox field to bulleted list
3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 1, 2010 (RSS)
By zip222 - June 1, 2010
I am using a regular textbox field in the cms for entering a list of people. But I am looking for a way to convert this straight list to a bulleted list on the public page.
Currently it outputs like this:
Name<br />
Name<br />
Name<br />
Name<br />
But I want it to output like this:
<li>Name</li>
<li>Name</li>
<li>Name</li>
<li>Name</li>
Is there a way to do this with php?
Currently it outputs like this:
Name<br />
Name<br />
Name<br />
Name<br />
But I want it to output like this:
<li>Name</li>
<li>Name</li>
<li>Name</li>
<li>Name</li>
Is there a way to do this with php?
Re: [zip222] Convert textbox field to bulleted list
By Jason - June 1, 2010
Hi,
Yes, you can do this with PHP. First, you have to turn your content into an array like this:
Just replace $content with your content from the database. After that, you just need to use a foreach loop to output your list.
Give that a try.
Hope this helps.
Yes, you can do this with PHP. First, you have to turn your content into an array like this:
$list = explode("<br/>",trim($content,"<br/>"));
Just replace $content with your content from the database. After that, you just need to use a foreach loop to output your list.
<ul>
<?php foreach($list as $item): ?>
<li><?php echo $item ?></li>
<?php endforeach ?>
</ul>
Give that a try.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Convert textbox field to bulleted list
By zip222 - June 1, 2010
perfect. and very useful.