Orangescale Studio

You're here: Home » Blog » Getting the most from Textpattern

Getting the most from Textpattern

by Thomas Arie Setiawan — March 28, 2006

After dealing with Textpattern for few weeks. It is time to get the most from Textpattern. Yeah, not many changes, I just want to make the content (and elements) in a good management.

Textpattern default page and "pages"

My previous layout used used the same page for the default page, and the main journal. So, why not make it a little bit different. The main differnce is the use of main header. In the main page, I put the latest entry in "special" place. The idea is to point a returning visitor (yeah, who visited this site directly) to the latest entry.

To do this, I use Textpattern tags: limit="1". Yeah, simple.

Still in the main page, the next "stage" is displaying next three entries (entry number 2 - 4). Here, I use offset="1" and limit="3".

After that, I put a list of eight older entries, starting from entry number 5 using offset="4" and limit="8".

txp:if and txp:else

txp:if and txp:else

In the page used for journal-related pages (main journal page, permalink, and categories), I use more conditional tags. This is an example:

"I want to display the recent comments only in main page, not in a single entry page."

To have such display, I use:

<txp:if_article_list>
<div>
<h3>Recent comments</h3>
<txp:recent_comments limit="10" break="li" wraptag="ul" class="" />
</div>
</txp:if_article_list>

Okey, what about displaying list of entries filtered by category? By default, when clicking a category name, it will use the main index page. So, let's have something different.

This is what I have in my default page (not main journal page).

<txp:if_category>
<txp:else />
some codes to display the header, with 1 latest entries.
</txp:if_category>
... other codes ...
<txp:if_category>
<txp:article form="journal-detail" limit="3" listform="journal-list" />
<txp:else />
<txp:article form="journal-detail" limit="3" listform="journal-list-front" offset="1" />
</txp:if_category>

If you read it carefully, you can understand that (do not get confused with list and listform:

* if it has nothing to do with categories, the main header area will be displayed.
* if it has nothing to do with categories (the regular default page, the looping entries will use this rule: <txp:article form="journal-detail" limit="3" listform="journal-list-front" offset="1" /> and,
* if the page displays list of entries from a spesific category, it will use this rule: <txp:article form="journal-detail" limit="3" listform="journal-list" />

No comments, one comment, and comments

I am not sure whether there is a method to display output text based on how many comments received. I mean, controlling the output texts. So, using some simple lines in the template, these are some points:

  • 0 comment -- *No comments*
  • 1 comment -- *One comment*
  • More than one -- *x comments*

Excerpt and body (without extended entry field)

One thing what makes Textpattern different from other blogtools is the entry fields. When I used WordPress, Movable Type, Expression Engine, I can see these fields: excerpt, body, and extended entry fields. But now, only excerpt and body.

To "solve" this kind of issue, I use pfa_beginning plugins by Philip Ashlock. It can help me displaying the first paragraph of an entry, or some sentences based on the length I specified.

Anyway, this method is a little bit tricky. In come cases, it will "break" the HTML. But, the point is that I can have I want. ;)

Enjoy!