Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-02-28 10:59:09
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
Style the first article different?
I’ve got the last 5 articles on my page.
Now I want to put the first one in a different div in order to style it different.
So what I want is this:
<code>
<div id=“highlight”>Last article</div>
<div id=“older”>The 4 other articles</div>
</code>
Is that possible?
Thanks.
Offline
Re: Style the first article different?
<code>
<div id=“highlight”><txp:article limit=“1” /></div>
<div id=“older”><txp:article limit=“4” offset=“1”/></div>
</code>
Offline
Re: Style the first article different?
You can even use the <code>listform</code> and <code>form</code> attributes of <code>txp:article</code> to use an absolutely different layout.
Offline
Re: Style the first article different?
Second possibility: txp:if_first_article.
Online
#5 2006-03-01 08:15:01
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
Re: Style the first article different?
Thanks.
This one works perfectly.
Offline
Re: Style the first article different?
A note about the first option: I suggested the same thing a while back and was reminded that doing so can <a href=“http://forum.textpattern.com/viewtopic.php?id=12728”>doing so can screw up your pagination</a>.
I don’t know if the pagination feature matters to you, but it’s something to keep in mind.
Offline
#7 2006-03-01 19:38:07
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Style the first article different?
The pagination problem shouldn’t be a problem anymore, now that we have the pageby attribute (should be added to the wiki).
Last edited by Mary (2006-03-01 19:38:20)
Offline
#8 2006-03-01 20:58:48
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
Re: Style the first article different?
I already liked the “txp:if_first_article” solution better….
Offline
Re: Style the first article different?
That’s what I figured, janw, but I figured that it couldn’t hurt to clarify. Especially in case people later find this thread through a search and decide to implement the first option.
Last edited by Elenita (2006-03-01 22:33:14)
Offline
#10 2006-03-01 23:16:43
- zem
- Developer Emeritus

- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Offline
#11 2006-07-21 08:48:16
- satellite360
- Member
- Registered: 2006-04-24
- Posts: 14
Re: Style the first article different?
Just started working with textpattern and having problems with this tag. What is wrong with this?
<code>
<txp:if_first_article>
<div id=“headline”>
<txp:article />
</div>
<txp:else />
<div id=“recent”>
<txp:article limit=“2” />
</div>
</txp:if_first_article>
</code>
It displays 2 articles (the 2 most recent) in the ‘recent’ div and nothing in the ‘headline’ div.
Thanks for any help.
Offline
Re: Style the first article different?
I think that txp:if_first_article is only valid inside an article form. You can use this markup:
<code><div id=“headline”><txp:article limit=“1”/></div>
<div id=“recent”><txp:article limit=“2” offset=“1”/></div></code>
Hope this helps.
Offline