foreach variations

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 3, 2008   (RSS)

By rez - December 2, 2008 - edited: December 2, 2008

Hello. I need to list specific records in groups on one page. In the code generator, i only see how to list all or a a certain number of records. Here is what I am trying to recreate:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<root>

<collection title="2008">
<news>
<date>25.10.2008</date>
<text>
<![CDATA[This is Dynamic HTML text from external XML file. ]]>
</text>
</news>
<news>
<date>20.10.2008</date>
<text>
<![CDATA[This is Dynamic HTML text from external XML file. ]]>
</text>
</news>
</collection>
<collection title="2007">
<news>
<date>25.10.2007</date>
<text>
<![CDATA[This is Dynamic HTML text from external XML file. ]]>
</text>
</news>
</collection>
<collection title="2006">
<news>
<date>25.10.2006</date>
<text>
<![CDATA[This is Dynamic HTML text from external XML file. ]]>
</text>
</news>
</collection>
</root>

Re: [rez] foreach variations

By rez - December 2, 2008 - edited: December 2, 2008


[font "Arial"]list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => 'collection_title = "Events"',

));

list($news2Records, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => 'collection_title = "Daily Specials"',

));

?>






Got it. You can put multiple lists on one page. so the "$news2Records" is a variable. Whats the "$newsMetaData" part for?

Also, how would i let the client create the "collection title"s? Currently, i am making the collections (categories) myself and using radio buttons. So I have to make a new list and <collection title =""> tag for each one. As you can see, the collection tag happens once for each group of items. Inside that tag, multiple items are listed. So this would have to be some nested loop situation? Any examples?