Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-16 03:09:37

repugnant
New Member
Registered: 2006-02-11
Posts: 2

Listing only a certain category on the front page

I have been struggling with TextPattern and the way it handles front pages. I have a section called “Journal” and that is the only section I want to appear on the front page. Ideally I’d like 5 entries to appear, and a link to the older entries. I can’t figure out the “article” and “if_article_list” tags. Is there a way to get them to do what I want? I have several other sections (like “photography” and “general news”) that I don’t want on the front page (they are displayed in a side bar with an article_custom tag).

I’ve been messing with this for two weeks – the FAQ and TextBook have not helped me :(

Offline

#2 2006-11-16 04:40:06

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Listing only a certain category on the front page

You mean section then, not category? Either way, use article_custom<txp:article_custom limit="5" section="journal" /> or for a category: <txp:article_custom category="myCategory" limit="5" />.

You can also get this out of TXP tags, using a few conditionals, or you can use the plugin glx_if (frontpage):

<txp:if_category>
	<!--Display category listing with some TXP tags -->
<txp:else />
	<txp:if_search>
		<!--Display search results-->
	<txp:else />
		<txp:article_custom limit="5" section="journal" />
		<p><a href="/journal/">Archives</a></p>
	</txp:if_search>
</txp:if_category>
  • <txp:article /> displays an article if you’re on an individual page
  • <txp:if_article_list> checks if we’re on an article list, which would be a section frontpage (/journal), homepage, category, or search listing. It doesn’t actually display articles.
  • <txp:if_individual_article> checks if we’re on an individual article. Like if_article_list in reverse

Last edited by jm (2006-11-16 04:50:51)

Offline

#3 2006-11-16 17:01:04

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Listing only a certain category on the front page

If you meant ‘section’ and not ‘category’, you don’t need <txp:article_custom /> nor a plugin. If you set only section ‘Journal’ to be displayed on the front page (in Presentation > Sections), <txp:article /> will do just that. So your code for the front page can be for example:

<txp:if_section name=""> <!-- if we're in section default -->
<txp:if_category> <!-- if we're on a category list page -->
<txp:article /> <!-- article tag for showing articles on a category page -->
<txp:else /> <!-- if we're on the front page -->
<txp:article limit="5" listform="article-list" />
<txp:article limit="..." offset="5" listform="title-list" />
</txp:if_category>
</txp:if_section>

The exact code depends on whether you’re using different page templates for your sections or just one.

<txp:article /> is context sensitive, meaning that it will display:

  • on the frontpage: a list of articles in sections that are set to be displayed on the front page
  • on a section page: a list of articles in that section
  • on a category page: a list of articles in that category
  • on an individual article page: that individual article
  • on a search results page: the search results

If you did mean ‘category’ you can use <txp:article_custom /> like in jm’s example.

Offline

#4 2006-11-19 06:52:01

repugnant
New Member
Registered: 2006-02-11
Posts: 2

Re: Listing only a certain category on the front page

jm, Els, thank you for the help. I used Els’ method and it worked just fine :)

I only have one section that I want to appear as regular articles on the front page, so turning off the other things worked perfectly.

Offline

Board footer

Powered by FluxBB