A question asked by many new to TXP is how can I have excerpts on the front-page with a read more link to the full article? It can be a little confusing trying to work this out as it relies on conditionals and nested tags. For a conditional to work you have to find some aspect which is different for the front-page and the single article page and that difference in this case is that the front-page is always an “article_list“ even if you only show one article as I do here, it is simply a list of one, whereas the single article page is an “individual_article“. Remember that. I shall return to it in another article soon. Anyway armed with that information we can set about solving our problem.

In plain English we want to say that if we are viewing an article_list, and if there is an excerpt, show the excerpt, and if there isn’t one show the full body however, if we are in individual_article view, show the full body always.

TXP uses the default FORM template to show articles so this is what you need to edit. You can create your own if you wish but you will need to add the attribute “form=FormName” to your article tag on your PAGE template to make TXP use it. You must also ensure that you save your form as an “article” type so that it is grouped with all other “article” type forms in the sidebar on the “Form” tab.

In TXP tag form our English translates to:-

<txp:if_article_list> <txp:if_excerpt> <txp:excerpt /> <txp:permlink>But there's more</txp:permlink> (optional) <txp:else /> <txp:body /> </txp:if_excerpt> <txp:else /> <txp:body /> </txp:if_article_list>

Nested tags can be confusing and will not work if nested incorrectly. Note how there are two “else“ tags in there. The first one is inside the “if_excerpt“ conditional tags so if there is an excerpt show the excerpt and the optional More… tag “else“ show the body.

The second “else“ tag comes after the closing “if_excerpt“ tag so it now relates to the “if_article_list“ conditional so we have “if_article_list“ do the excerpt conditional block “else“ just show the body.

Once you get used to it you should find it easy to nest tags in this way for all kinds of stuff because, if nothing else, it is completely logical.