Textpattern Notes 6: Overriding Forms
One of the most frequent questions I get asked about my Textpattern setup is how I do change content per article on the journal homepage. The majority of the time I have excerpts of each article with a link to read the full article, but sometimes I have very short articles that are shown in their entirety, and these just have the link for ‘Permalink’.
Its a feature of TXP that a lot of users I’ve come across don’t use. Next time you’re in your ‘write’ tab, look on the left under ‘advanced options’. That drop down called ‘override form’ will allow you to alter the display of the content per article.
Here’s how I use it:I have a default article form for displaying posts on the journal front page. This outputs a title, link to full article and the excerpt. Here it is in cut-down form:
<h2><txp:permlink><txp:title /></txp:permlink> <txp:posted /></h2> <txp:if_article_list> <p><txp:permlink>Read the full entry</txp:permlink> <txp:excerpt /> </txp:if_article_list>
(The conditional comments
<txp:if_article_list> mean these only show up on the homepage)
I also have another form, which uses similar markup, except that I use the whole body of the article, not just the excerpt. The link text changes to reflect this, so ‘Read full entry’ becomes ‘Permalink’. Here’s the cut-down version of that form:
<h2><txp:permlink><txp:title /></txp:permlink> <txp:posted /></h2> <txp:if_article_list> <p><txp:permlink>Permalink</txp:permlink> <txp:body /> </txp:if_article_list>
Then when I have just a small article to post, I just choose the relevant form from the ‘Overide form’ list. This overrides whatever you’ve set in your page template, not just if you’ve left it to use the ‘default’ article form. This isn’t really stretching its possibilities, and I’d love to know what, if any, ways you use this feature.