Displaying multiple records that have same list field value
3 posts by 3 authors in: Forums > CMS Builder
Last Post: April 20, 2010 (RSS)
By depdesign - April 20, 2010
I'm trying to find a way where I can display records from a section by the value from a pulldown list created in the CMS.
For example, below is a sample dropdown list field (Field Name: entertainment) in the CMS for a section titled "media".
Music|Compact Disc
Music|Radio
Music|Ipod
News|Newspaper
News|Televison
I want to display records on a page that have the value of Music to appear on a page.
Below is the code I tried:
This does not display anything.
If I do this....
It only displays the one record that has Compact Deisc selected in the list.
For example, below is a sample dropdown list field (Field Name: entertainment) in the CMS for a section titled "media".
Music|Compact Disc
Music|Radio
Music|Ipod
News|Newspaper
News|Televison
I want to display records on a page that have the value of Music to appear on a page.
Below is the code I tried:
list($mediaRecords, $mediaMetaData) = getRecords(array(
'tableName' => 'media',
'where' => "entertainment = \"Music\"",
));
This does not display anything.
If I do this....
list($mediaRecords, $mediaMetaData) = getRecords(array(
'tableName' => 'media',
'where' => "entertainment = \"Compact Disc\"",
));
It only displays the one record that has Compact Deisc selected in the list.
Dan Perez
Re: [depdesign] Displaying multiple records that have same list field value
By gkornbluth - April 20, 2010
Hi depDesign,
I found this and it might help.
The perPage code is optional of course.
Hope it works.
Best,
Jerry Kornbluth
I found this and it might help.
To show only record from a specific region you can use a MySQL Where query like this: region = "north west"
You can either enter that in the code generator (at the bottom under "Filter Results") or in the viewer code like this:
Code
list($records, $recordMetaData) = getRecords(array(
'tableName' => 'bios',
'perPage' => 5,
'where' => 'region = "north west"',
));
The perPage code is optional of course.
Hope it works.
Best,
Jerry Kornbluth
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [depdesign] Displaying multiple records that have same list field value
By Jason - April 20, 2010
Hi,
If there is any other kind of search happening on the page, that may be causing the problem. Try this:
If this doesn't work, replace the 'allowSearch' line with this:
Give that a try and let me know if it works.
Then run the script and post what it's outputting.
Give that a try and let me know if it works.
If there is any other kind of search happening on the page, that may be causing the problem. Try this:
list($mediaRecords, $mediaMetaData) = getRecords(array(
'tableName' => 'media',
'allowSearch' => 0,
'where' => "entertainment = \"Music\"",
));
If this doesn't work, replace the 'allowSearch' line with this:
Give that a try and let me know if it works.
'debugSql'=>1,
Then run the script and post what it's outputting.
Give that a try and let me know if it works.
---------------------------------------------------
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/