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 9, 2009
Any help would be very much appreciated...
You can see the search page at www.fanmarketplace.com/finddeals.php
thx in advance!!!
Brian
Re: [blillie] How do i dynamically populate a drop down menu from one of my fields
By Damon - July 10, 2009
Here is a code example for you:
Based on having a Categories section that use the Title field for the names.
<?php
require_once "/path/to/your/viewer_functions.php";
list($categoriesRecords, $categoriesMetaData) = getRecords(array(
'tableName' => 'categories',
'allowSearch' => '0',
));
?>
<!-- ADD THIS SELECT CODE INTO YOUR SEARCH FORM -->
<select>
<option value="">Any</option>
<?php foreach ($categoriesRecords as $record): ?>
<option value="<?php echo htmlspecialchars($record['title']) ?>"><?php echo htmlspecialchars($record['title']) ?></option>
<?php endforeach; ?>
</select>
Give this a try and let me know how you work out.
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 10, 2009
Fatal error: Call to undefined function: getrecords() in /home/fanmarke/public_html/finddeals2.php on line 3
===================
Here is the code I used:
<?php
require_once "http://www.fanmarketplace.com/cmsAdmin/lib/viewer_functions.php";
list($categoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
'allowSearch' => '0',
));
?>
and then for the search field i used:
<select>
<option value="">Any</option>
<?php foreach ($categoryRecords as $record): ?>
<option value="<?php echo htmlspecialchars($record['title']) ?>"><?php echo htmlspecialchars($record['title']) ?></option>
<?php endforeach; ?>
</select>
I changed where you had "categories" to "category" as that is the Field Name on the backend.
I'm testing it on this page: www.fanmarketplace.com/finddeals2.php
thx
Brian
Re: [blillie] How do i dynamically populate a drop down menu from one of my fields
By Damon - July 10, 2009
You are using the URL here:
require_once "http://www.fanmarketplace.com/cmsAdmin/lib/viewer_functions.php";
when you need to be using the server path instead.
Use the Code Generator to find out the correct path:
Admin > Section Editors - modify Category then click the "Viewer Code Generator" button.
Once you have the right path to the view_functions.php file, everything should work.
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 10, 2009
getRecords(category): Couldn't load schema for 'category'!
Re: [blillie] How do i dynamically populate a drop down menu from one of my fields
By Damon - July 10, 2009
If that doesn't work can you reply with your page as an attachment so I can look at the code.
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 10, 2009
thx
Brian
Re: [blillie] How do i dynamically populate a drop down menu from one of my fields
By Dave - July 10, 2009
interactivetools.com
Re: [Dave] How do i dynamically populate a drop down menu from one of my fields
By blillie - July 10, 2009
do you want me to email you the login and pw to access the backend so you can see what i'm seeing?
thx
Brian
Re: [blillie] How do i dynamically populate a drop down menu from one of my fields
By Dave - July 10, 2009
Let me know if that works for you.
interactivetools.com