The front-page of TXP is a subject all on it’s own. It comes under the default section and if you go to the Sections tab in your admin. you will see that it doesn’t have all the options that the other sections have. In a new install this section uses the default page template and default style. Changing the style used is one thing but for my own part I can not see any point in changing the template used. I mean the default page template for the default section just seems the most logical set-up to me.

Some important points of note about the default section.

  1. It can not be deleted.
  2. It is a global section and every article you create belongs to it as well as the section you may allocate the article to. This means that all your articles would appear on the front-page if you didn’t filter them. Filtering is done in the “Sections” tab where you can tell TXP which section can or can’t appear on the front-page.
  3. In versions of TXP prior to v4.0.4 it’s name did not appear in the URL of the page. This meant that if you wanted to use the “txp:if_section” tag to specify the default section you needed to use name=”“. Since v4.0.4 it has been defined as “default” which appears in the URL and in a “txp:if_section” tag you now use name=“default”. In my themes, in order to allow for old and new versions, I use name=”,default”.
  4. It is used to display category lists and search results by default. Both can be sent elsewhere but that’s another article.

In a new TXP install the front-page is set up to display your blog. This isn’t necessary. The current design for The Bombsite uses the front-page as an “entry-point” and the blog has it’s own section. If your blog is the focal point of your site you may want to keep it as your front-page but if you don’t it is easy enough to change.

The Sections

First you will see that you already have 3 sections in the Sections tab – default, about and article. Default has to be the front-page, article could be for your blog and about is for an about page which we are not concerned with here so we will ignore it other than to check the section permissions and ensure that about is NOT selected by default and does NOT appear on the front-page. Whether you want it to be searchable and appear in your feeds (syndicated) is up to you. Whilst you do this please note that each section has it’s own save button. You can only modify and save one section at a time. Don’t try altering lots of them and saving at the bottom. It just doesn’t work. OK?

The Blog Page

Now in a new install the default and article sections are set to use different page templates so half the job is done for you. First you should set the permissions for the article section so that it CANNOT appear on the front-page and is NOT selected by default.

With the templates already chosen for us (you can of course set up a different section for your blog with another template if you wish) and section permissions set we now need to modify the 2 page templates accordingly. We’ll start with the archive template for the blog as it is easier and you can learn a bit before we tackle the default template.

Go to the Pages tab and select the archive template. The template is set up to view individual articles in a new install. We need to tell it how to do article lists as well. There are tags called conditionals. They ask the if question. They say “if something is this then do this, else do this instead”. One of these conditionals is “txp:if_article_list” and we are going to use it to tell the template what to do for each type of view.

<txp:if_article_list> <txp:article limit="5" form="articleList"> <p><txp:older>Previous</txp:older> <txp:newer>Next</txp:newer></p> <txp:else /> <txp:article form="singleArticle"> <p><txp:link_to_prev><txp:prev_title /></txp:link_to_prev> <txp:link_to_next><txp:next_title /></txp:link_to_next></p> </txp:if_article_list>

So what we have is “if we are viewing an article list, display 5 articles per page maximum using the articleList form then display the paging links else (if an individual article) display the article using the singleArticle form followed by the previous and next article links”. Note that for the “individual article” view you don’t need to specify the limit as TXP will only display one article anyway.

Forms are smaller templates. You can find them by going to the Forms tab. You use forms to create your format for more detailed chunks of information such as your articles, or you can also use them for information that gets repeated throughout the site such as your header, footer, sidebars, horizontal navigation etc. Having these segments as forms allows you to make changes to them once but have the changes apply to your whole site. The article tag will use the default form if no form is specified. The attribute “form” is to specify the form used to display the article/s if you don’t want to use the default form.

The Front Page

With our blog page sorted we now need to select the default page template from the Pages tab.

Now as I mentioned your default template or whichever template you use for the default section will need to display not only your front-page contents, but also any category lists that are called for and also your search results. Here is what we require:-

If these are search results, show them using this form, else, if this is a category list, show the list using this form, else, show anything else using this form, end if.

In TXP tags form that translates to:-

<txp:if_search> <txp:article limit="10" form="SearchForm" /> <p><txp:older>Previous</txp:older> <txp:newer>Next</txp:newer></p> <txp:else /> <txp:if_category> <txp:article limit="5" form="CategoryForm" /> <p><txp:older>Previous</txp:older> <txp:newer>Next</txp:newer></p> <txp:else /> <txp:article limit="5" /> </txp:if_category> </txp:if_search>

In this example I have referred to 2 forms, SearchForm and CategoryForm, which could be form templates that you have created to show search results and/or category lists in a different format to your front-page articles. I have also included paging tags for the search and category list views as you may not require them for your front-page depending on what it is that you display there. If you did want them for all 3 views then you could have a single instance of them below these tags which would always display.