Display 1 record from mutliple lists in order by date

7 posts by 3 authors in: Forums > CMS Builder
Last Post: August 24, 2010   (RSS)

By s2smedia - August 24, 2010

I have a tab on my page that shows the most recent News, Events, Media

I would like it to show the first most recent record from each list.. but have it in order by date..

Re: [s2smedia] Display 1 record from mutliple lists in order by date

By Jason - August 24, 2010

Hi,

So, if I understand correctly, you want to display the most recent record for news, events, and media. Only 1 record per section. But then display those 3 records, ordered by date. Is that right?

If so, take a look at this post. I think this will get you started.
http://www.interactivetools.com/forum/gforum.cgi?post=82652#82652

Let me know if you run into any issues.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [s2smedia] Display 1 record from mutliple lists in order by date

By Jason - August 24, 2010

Hi,

I took a quick look at your code and I can't see any of the code from the other forum post:
http://www.interactivetools.com/forum/gforum.cgi?post=82652#82652

Try integrating that code in and let me know if you run into any difficulties.

If you'd like, we can do the integration for you through our consulting service. Just send an email to consulting@interactivetools.com and we can get you a quote.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Display 1 record from mutliple lists in order by date

By s2smedia - August 24, 2010

ok.. is there a way to just have it display 1 record..
but using the code in the body, not the code in the header..

ex.
<?php foreach ($eventsRecords as $record): ?>
<ONLY DISPLAY 1>
<div class="<?php echo date("D, M j, Y g:i:s", strtotime($record['date'])) ?>" title="<?php echo $record['title'] ?>">
<?php echo $record['content'] ?><br /><br />
<?php echo join(' | ', getListLabels('events', 'tag', $record['tag'])); ?>
</div>
<?php endforeach ?>

I can just do it this way untill i fugre the other way out

Re: [s2smedia] Display 1 record from mutliple lists in order by date

By s2smedia - August 24, 2010

using the ;break ?

Re: [s2smedia] Display 1 record from mutliple lists in order by date

By Chris - August 24, 2010 - edited: August 24, 2010

Hi s2smedia,

Yes, you can insert a BREAK statement after displaying the first record and PHP will break out of the foreach, skipping the rest of the records:

<?php foreach ($eventsRecords as $record): ?>
<div class="<?php echo date("D, M j, Y g:i:s", strtotime($record['date'])) ?>" title="<?php echo $record['title'] ?>">
<?php echo $record['content'] ?><br /><br />
<?php echo join(' | ', getListLabels('events', 'tag', $record['tag'])); ?>
</div>
<?php break ?>
<?php endforeach ?>


I hope this helps!
All the best,
Chris