- Joined
- Jun 1, 2010
- Posts
- 548
- Reaction score
- 2
At the moment I use the code below to display all articles from my database in small, rectangular boxes with a small thumbnail on one side. However, I would like to display the latest article as a large picture with the other info underneath. I thought it would be (and probably is to non-noobs) simple to do but I can't workout how to grab the latest article. I can do everything styling wise, it's just getting the latest article. The articles all have an incremental id. Any help would be much appreciated!
<ul id="headlines">
<?php foreach ( $results['articles'] as $article ) { ?>
<li>
<?php if ( $imagePath = $article->getImagePath( IMG_TYPE_THUMB ) ) { ?>
<a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><img class="articleImageThumb" src="<?php echo $imagePath?>" alt="Article Thumbnail" /></a>
<div id="shortsummary">
<h2><a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><?php echo htmlspecialchars( $article->title )?></a>
<span class="pubDate"><?php echo date('j F', $article->publicationDate)?></span>
</h2>
<p class="summary">
<?php } ?>
<?php echo htmlspecialchars( $article->summary )?>
</p></div><?php } ?>
</li>
</ul>
<ul id="headlines">
<?php foreach ( $results['articles'] as $article ) { ?>
<li>
<?php if ( $imagePath = $article->getImagePath( IMG_TYPE_THUMB ) ) { ?>
<a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><img class="articleImageThumb" src="<?php echo $imagePath?>" alt="Article Thumbnail" /></a>
<div id="shortsummary">
<h2><a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><?php echo htmlspecialchars( $article->title )?></a>
<span class="pubDate"><?php echo date('j F', $article->publicationDate)?></span>
</h2>
<p class="summary">
<?php } ?>
<?php echo htmlspecialchars( $article->summary )?>
</p></div><?php } ?>
</li>
</ul>