Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-29 19:17:38

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

[howto] Separate or give a unique style to the most recent article

The next techniques can be used both to put your most recent article in a different place in your page template (so, it’s separated from older articles) or to give an unique style to the most recent article (or both at the same time)

To separate the most recent article

  • In your page template, put this line wherever you want to display your most recent article: <txp:article limit="1" />
  • Also in your page template, put this line wherever you want to display your five older articles: <txp:article offset="1" limit="5" />

To give a unique style to the most recent article

It is exactly the same as above, but you have to play with the “form” attribute (or “listform”, if you want to style the most recent article in a list).
So:

  • In your page template, put this line wherever you want to display your most recent article using “mySpecialForm”: <txp:article limit="1" form="mySpecialForm" />
  • Also in your page template, put this line wherever you want to display your five older articles using “myRegularForm”: <txp:article offset="1" limit="5" form="myRegularForm" />
  • In “Presentation -> Forms”, create those two forms (“mySpecialForm” and “myRegularForm”) and play with the way you want to display your most recent article. Of course, you can also play with “limit” and “offset” attributes to apply a special style to the two most recent articles (limit="2" for the first line above, and offset="2" for the second one).

That’s all!

Do you know another method to do the same? or perhaps an improvement to this one?
Share it here!

note:
This method has been inspired from the one in this thread, where andreas suggested the same, but using <txp:article_custom /> in the second line.
I just wanted to show that it is possible to do the same using only <txp:article />, and I think it is easy and it’s a more correct approach, regarding this FAQ and this one too.

(updated code display. -Els)

Last edited by els (2009-09-27 12:59:29)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB