简体   繁体   English

Joomla模板覆盖最新的类别文章

[英]Joomla Template Override for newest Article of Category

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. 我的目标是为该类别的最新文章显示一个额外的div(带有背景图像)。 And this should only effect the newest article. 这应该只影响最新的文章。

So, as I am not familiar with the Joomla-API. 所以,因为我不熟悉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? 我现在想知道,如果一篇文章是该类别的最新文章,最好的方法是确定(在PHP / MySQL /中)?

Thanks for a reply (Btw. I am using J1.6) 谢谢你的回复(顺便说一下。我使用的是J1.6)

Ripei Ripei

This code should do the trick 这段代码应该可以解决问题

    $db=& JFactory::getDBO();
    $query = 'SELECT * FROM #__content ORDER BY created DESC';
    $db->setQuery($query);
    $showcat = $db->loadObjectList();

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. 然后,您可以在循环中添加一个计数器,该循环调用文章视图并为模板覆盖中的第一篇文章显示其他DIV。 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). 纯CSS解决方案是使用:first-child选择器来更改第一篇文章的外观(不添加额外的DIV)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM