25/05/05
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.
9
Tags: 


Previous





Download our vCard
Andrea said 1234 days ago:
Nice post. I use TXP override forms as well in the A-Z index for Humboldt State University. For example, on this page, the main form uses article titles and custom fields to output the index. For the last entry, I use an override form to accomodate the different type of data the listing includes.Dave said 1234 days ago:
Cheers Jon – I always find the way of doing something the hard way, little did I know there was a damn form to pull it off right under my nose!Mikkel Malmberg said 1234 days ago:
Nice way to use it .. Indeed ..It seems to me that others always find a different, much easier way of doing the stuff I’m doing the hard way – but hey, that’s why some are rich and some aren’t right?
Garrett said 1234 days ago:
Darnit Jon! Now I’m going to go look for an excuse as to how I can use this on my site. Well, given the unfortunate simplicity, that may not be a bad thing. Thanks for the tip.Nathan Smith said 1232 days ago:
Jon, do you usually type in your excerpt manually, or do you have a nice plugin that generates it for you based on the article? If so, what is the plugin?Great writeup by the way, I’ve been using the if_article_list for my Flickr photos, so they aren’t on every archived article.
Tom Fadail said 1230 days ago:
That is what I have on my form, but for some reason my permalink page does not have any articles or anything in it….just the title
any ideas?
Tom Fadial said 1230 days ago:
Sorry, couldn’t figure out how to show the code, but any ideas???
Lisa Giovanni said 1228 days ago:
Thanks for the great post! That may be a very useful for me.Rachel said 1224 days ago:
hey, i never even noticed ‘override form’... very cool! thanks for the heads-up.