Find latest record otherwise all others if statement
Probably not the most elegant approach, but if you sort by either createdDate or updatedDate (which ever makes more sense) and limit the load to one record, something like:
list($digital_magazineRecords, $digital_magazineMetaData) = getRecords(array( 'tableName' => 'digital_magazine', 'allowSearch' => '0', 'orderBy' => "createdDate DESC", 'limit' => '1', 'loadUploads' => true, 'allowSearch' => false, ));
That should give you the newest record and you could output any information about that record you wanted to.
You could also create a variable from the record number of that newest record, like $newestRecNum
You could then do a new load records call without the limit, sorting the records the way you want to.
If you create another record number variable like $allRecNums within the second foreach loop, you could compare the 2 variables and only echo the title of those records where there's no match to the $newestRecNum variable.
Hope that gives you some ideas.
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
To do something like this, you can modify the foreach to provide the "key" of the current element which, in the case of these records, should be a numerical index starting with 0. This can then be used to check for the first item. It could look something like this:
<?php foreach ($digital_magazineRecords as $key => $record): ?> <?php if ($key == 0): ?> <h1><?php echo htmlencode($record['title']) ?></h1> <?php foreach ($record['cover_image'] as $index => $upload): ?> <img src="<?php echo htmlencode($upload['thumbUrlPath2']) ?>"/> <?php endforeach ?> <?php else: ?> <h4><?php echo htmlencode($record['title']) ?></h4> <?php endif; ?> <?php endforeach ?>
Note that this checks for the first item in the records array, which isn't necessarily the newest record, depending on what parameters are being used in getRecords().
Let me know if that suits your needs, or if you have any questions!