Multi-Select Roundabout!
5 posts by 2 authors in: Forums > CMS Builder
Last Post: September 13, 2010 (RSS)
Hi, All
I'm having one of those days where the simplest of problems is causing my brain to turn to cheese!
I want to use the data from a multi-select menu on a detail page - but I simply can't work out how to do it!
In this instance, each Value is a URL and each Label is the name of a website. The idea is that the author can select from a pre-configured pool of websites and show these as a list of links beneath an article.
Should be simple but it just ain't happenin' today!
Wibble...
Perch
I'm having one of those days where the simplest of problems is causing my brain to turn to cheese!
I want to use the data from a multi-select menu on a detail page - but I simply can't work out how to do it!
In this instance, each Value is a URL and each Label is the name of a website. The idea is that the author can select from a pre-configured pool of websites and show these as a list of links beneath an article.
Should be simple but it just ain't happenin' today!
Wibble...
Perch
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.
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/
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:
I would like the to use the code to construct a simple list of links along the lines of:
It's a rough example but you can see the idea.
:0)
Perch
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:
Next, we just need to output them:
That should do it.
Hope this helps.
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/
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
Thanks Jason. These things are so bloomin' easy when you know how!
:0)
Perch