Multiple Where statements from one section...

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 8, 2012   (RSS)

By crazyfish - November 7, 2012

The client has a section named blog. It has a list from another section named blog_sections. List option from database, checkboxes, option values -num option labels - title.

Options include Press, Events, Inspirations etc.

On the home page they would like the one most recent post from each option to be displayed as seen here http://americadesigns.com/index1.php

I can't get my head wrapped around how to add the "where" type of statement in each loop, or one by one if I have to...

Originally it was the most recent six and has changed. Code for that process shown below.


// load records
list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'perPage' => '6',
));


<?php foreach ($blogRecords as $record): ?>
<div class="blog_box">
<?php foreach ($record['thumb'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /></a><br/>
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
<?php endif ?>

<?php endforeach ?>
<div class="large"><?php echo $record['title'] ?></div>
<br/>
<?php echo $record['summary'] ?><br/>

</div>
<?php endforeach ?>


So - I need either one most recent record from each option shown or a way to filter out at this level options.

I can't seem to get head wrapped around the logic nor the code to accomplish this task.
As always, thanks for your help.

Re: [greg] Multiple Where statements from one section...

By crazyfish - November 8, 2012

I'm not getting this point
"You will need to change $record['blog_sectionsFields:values'] to the name of the field that contains the values from blog_sections and add :values to the end of it. "

In the table blog_sections, there are six records in which the only field used is title. Those are Press, Events, Inspirations, Installations, Arrivals, Departures.

In the table blog, the variables are in a field named section.

I've tried every variation a non php guy could think of with no results. The page is here http://americadesigns.com/index2.php. The image is coming from the first 12 lines of code which probably should be deleted, and the image moved into your code.

I thank you for your help!