Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-09-22 17:55:53

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

displaying last post from each of several sections on one page

This should be easy and there has to be a way to do it, but I’m darned if I can find it.

I’ve got two sections: news and happenings. On the home page I want to include the latest article from each, but in different parts of the page.

So, I set up two different divs, one for news and one for happenings. The first has this:

<txp:article form="last-news" limit="1" />

Then I created a form named “last-news” with code like this:

<txp:if_article_section name="news">
  <h2><txp:permlink><txp:title /></txp:permlink></h2>
  <h3>by <txp:author /></h3>
  <txp:excerpt />
  <h4>published <txp:posted /></h4>
  <p><txp:permlink>more</txp:permlink></p>
</txp:if_article_section>

This works fine except that the limit condition means that the form only checks the first record it encounters. If this is not a news article then nothing shows up.

How do I get just the latest article from the given section?

Is there any way to do this without a form for each section? Because that will get tedious — I need four or more sections eventually.

(Edited: you need an empty line before the bc. -Els)

Last edited by els (2007-09-22 20:51:50)


robin

Offline

#2 2007-09-22 17:56:56

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: displaying last post from each of several sections on one page

Well, I thought it was just the preview screwing up for my code snippets but apparently not. Can anyone explain properly how to insert code? Because the FAQ page referenced in the help is either wrong or not so helpful.


robin

Offline

#3 2007-09-22 18:02:09

obeewan
Archived Plugin Author
From: Stockholm, Sweden
Registered: 2004-08-12
Posts: 319
Website

Re: displaying last post from each of several sections on one page

Use the @ symbol for short code snippets (no line breaks) and bc. for code snippets that span multiple lines. bc. like bq. needs an empty row above and below them to work (or the start of the whole message).

short code snippet using @

longer
code
snippet
using bc.

For the first question at hand. Why not use txp:article_custom instead of txp:article so you can then specify the section in the page rather then the form?


Plugins: ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1

“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu

Offline

#4 2007-09-22 21:54:55

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: displaying last post from each of several sections on one page

Thank you êta for clear answers to both of my questions.

The difference between the “article” and “article_custom” tags was not apparent to me, even though I read the entry on same. After one day I am liking textpattern but not at all liking some of the nomenclature, which is willfully obscure in some cases. Perhaps someday the tags will be more appropriately named, so it is obvious which ones are supposed to be inside article forms and which are not.

Not to mention that “forms” should be “snippets” and “pages” should be “templates”. That would save a good percentage of newbie questions!


robin

Offline

Board footer

Powered by FluxBB