Multi-Select Roundabout!

5 posts by 2 authors in: Forums > CMS Builder
Last Post: September 13, 2010   (RSS)

Re: [Perchpole] Multi-Select Roundabout!

By Jason - September 13, 2010

Hi,

If you could attach the .php file you're currently working with, I can take a look at this for you.

Thanks.
---------------------------------------------------
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] Multi-Select Roundabout!

Hi, Jason -

Thanks for the offer of support. I'm not looking for anything grand, just a simple guide to constructing the code.

When I use $showme I have the following bits of code to work with from the multi-select list:

[offsite_items] => url1 url2 url3
[offsite_items:labels] => Array
(
[0] => Website one
[1] => Website two
[2] => Website three
)

[offsite_items:values] => Array
(
[0] => url1
[1] => url2
[2] => url3
)


I would like the to use the code to construct a simple list of links along the lines of:

<ul>
<?php foreach $record['offsite_item'] as xyz ?>
<li><a href="xyz['values']">xyz['labels']</a></li>
<?php endforeach ?>
</ul>


It's a rough example but you can see the idea.

:0)

Perch

Re: [Perchpole] Multi-Select Roundabout!

By Jason - September 13, 2010

Hi Perch,

Try something like this:

First, we're going to combine your two arrays into one:

$offsite_items = array_combine($record['offsite_items:values'],$record['offsite_items:labels']);

Next, we just need to output them:

<ul>
<?php foreach ($offsite_items as $value => $label): ?>
<li><a href="<?php echo $value;?>"><?php echo $label;?></a></li>
<?php endforeach ?>
</ul>


That should do it.

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/

Re: [Jason] Multi-Select Roundabout!

Brilliant!

Thanks Jason. These things are so bloomin' easy when you know how!

:0)

Perch