How do i dynamically populate a drop down menu from one of my fields

19 posts by 4 authors in: Forums > CMS Builder
Last Post: July 16, 2009   (RSS)

By blillie - July 10, 2009

Okay, i think we're getting there now. If you go to:

www.fanmarketplace.com/finddeals2.php

you'll see that it isn't just putting the categories in there now, it's putting them in for each time they're used. Also, if i select one it just pulls up everything on the listings page and doesn't seem to actually work.

Can you see what I'm talking about?

thx

Brian

Re: [blillie] How do i dynamically populate a drop down menu from one of my fields

By Dave - July 12, 2009

Hi Brian,

The reason everything is coming up is because you need to give the category search pulldown a name. Right now it is:
<select>

Try changing it to:
<select name="category_match">

For more details on advanced search options see this page in the docs:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

As for the repeating, do you have a separate section for just category names or do you have them just entered as text options in the field editor? (Put another way, when you edit the "category" field in the field editor, what is "List Options" set to?)
Dave Edis - Senior Developer
interactivetools.com

By blillie - July 14, 2009

I've attached a screenshot for you to review and hopefully answer your question... i did what you said but they are still repeating.
Attachments:

screen-shot.jpg 131K

Re: [ross] How do i dynamically populate a drop down menu from one of my fields

By blillie - July 15, 2009

Here is the file.

thx

Brian
Attachments:

finddeals2_001.php 12K

Re: [blillie] How do i dynamically populate a drop down menu from one of my fields

By Damon - July 15, 2009

Hi Brian,

It looks like you have working now here:
www.fanmarketplace.com/finddeals.php


Here is the code I came up with:

<?php foreach ($categoryRecords as $record):
$productCategory[] = $record['category'];
endforeach;
?>
<?php $productCategory = array_unique($productCategory); ?>

<select name="category_match">
<?php foreach ($productCategory as $record): ?>
<option value="<?php echo htmlspecialchars($record) ?>"><?php echo htmlspecialchars($record) ?></option>
<?php endforeach; ?>
</select>


It grabs all the product categories and puts them into an array. Next is removes duplicate category names and then outputs in your select list.

If you are still having any issues with this, send us an email to support@interactivetools.com with your login details (URL, username and password) so we can help. Dont' t post login details here.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] How do i dynamically populate a drop down menu from one of my fields

By blillie - July 15, 2009

That worked great!!! Thx

One more quick question that hopefully is an easy fix... if you look at the sidebar navigation it lists the categories as links... can you help me with some code to have that automatically populate instead of me having to manually put them in....

I've attached the file that holds the code for that area of the website.

thx

Brian
Attachments:

categorynav.php 5K

Re: [blillie] How do i dynamically populate a drop down menu from one of my fields

By ross - July 16, 2009

Hi Brian

Glad that worked :).

To get it going with links, you basically use the same code. You can just take out the <select> and </select> tags then change the <option> into an <href>

Give it a shot and let me know how you make out :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] How do i dynamically populate a drop down menu from one of my fields

By blillie - July 16, 2009

Worked like a charm!

thx