select first item from mod_articles_category
Moderators: ooffick, General Support Moderators
Forum rules
-
- Joomla! Apprentice
- Posts: 19
- Joined: Wed Mar 09, 2016 12:00 pm
select first item from mod_articles_category
For a layout override on mod_articles_category, i would like to show the first item in a different way of the rest. Default layout outputs all items the same (foreach.... etc). How do i target the first item specificly and let the rest follow?
-
- Joomla! Virtuoso
- Posts: 4025
- Joined: Mon Nov 25, 2013 4:35 pm
- Location: Montreal, Canada
- Contact:
Re: select first item from mod_articles_category
You can style the first item differently using CSS. You can do this with the first-child selector. For example, if you want the font color of the first time to be red, you can do this the following way:
Where modulecss is the CSS of the module (that you can set at the module level).
Code: Select all
.modulecss ul li:first-child {
color: red;
}
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter
https://twitter.com/itoctopus - Follow us on Twitter
-
- Joomla! Apprentice
- Posts: 19
- Joined: Wed Mar 09, 2016 12:00 pm
Re: select first item from mod_articles_category
thnx, but i get that method. Point is i want some different classes on the first item (making the first item 6 colums and the rest 3, for example), so i'm looking for a way to target the first item within the module itself, not trough css
- toivo
- Joomla! Master
- Posts: 17443
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: select first item from mod_articles_category
If you need to modify the PHP code and change the current CSS classes of the first article, you can create an override of the file default.php in the html folder of your template:
https://docs.joomla.org/J3.x:How_to_use ... _Overrides
https://docs.joomla.org/Layout_Overrides_in_Joomla
https://docs.joomla.org/J3.x:How_to_use ... _Overrides
https://docs.joomla.org/Layout_Overrides_in_Joomla
Toivo Talikka, Global Moderator
-
- Joomla! Apprentice
- Posts: 19
- Joined: Wed Mar 09, 2016 12:00 pm
Re: select first item from mod_articles_category
Thnx for your answer, but it isn't the answer that i was looking for. I know how to do overrides, i'm looking for a php method to target the first item in an itemloop on mod_articles_category, as discribed in my OP.toivo wrote:If you need to modify the PHP code and change the current CSS classes of the first article, you can create an override of the file default.php in the html folder of your template:
https://docs.joomla.org/J3.x:How_to_use ... _Overrides
https://docs.joomla.org/Layout_Overrides_in_Joomla
- toivo
- Joomla! Master
- Posts: 17443
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: select first item from mod_articles_category
If you would like someone to do the PHP coding for you, you could perhaps post a request to the Professional Development Services forum at http://forum.joomla.org/viewforum.php?f=177
Toivo Talikka, Global Moderator
-
- Joomla! Exemplar
- Posts: 8808
- Joined: Sat Oct 01, 2011 7:06 pm
Re: select first item from mod_articles_category
The standard trick for that is to introduce a boolean initialized to true. Inside the loop you test for true and do whatever you need to do once and set the boolean to false.
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!