Reputation: 432
Guys, I've got an problem... I am using an alternative layout for articles in a certain category. My aim is to display an extra div (with an background-image) for the Newest article of the category. And this should only effect the newest article.
So, as I am not familiar with the Joomla-API. I would now like to know what's the best way to determine (in PHP/MySQL/whatever) if an article is the newest article of its category?
Thanks for a reply (Btw. I am using J1.6)
Ripei
Upvotes: 0
Views: 566
Reputation: 129
when you say you already use an alternative layout, do you display the articles in chronological order (newest first, see the corresponding menu item properties)? Then you could add a counter to the loop which calls the article view and display an additional DIV for the first article in your template override. A pure CSS solution would be to use the :first-child selector to change the appearance of the first article (without adding an extra DIV).
Upvotes: 1
Reputation: 9296
This code should do the trick
$db=& JFactory::getDBO();
$query = 'SELECT * FROM #__content ORDER BY created DESC';
$db->setQuery($query);
$showcat = $db->loadObjectList();
Upvotes: 1