Textpattern Pages

Part 4: Textpattern Pages

I will be leaving this entry in the series largely open because it will likely be covered more thoroughly in Nathan’s article.

Textpattern pages are the basic template for your site. They are displayed based on sections and control the layout of your site. Accompanying page templates are your CSS styles which can also be regulated by sections.

I’ve often heard praise of Wordpress’ easy templating system, but I’ve used both and have found Textpattern’s to be much simpler. The tags have an intuitive XML-style structure and can be easily generated from a more descriptive popup. Also, direct form outputs can be used to emulate PHP includes so you don’t have to modify each page template.

Designing a website for Textpattern is very simple. Simply follow your normal process and then it is only a few minutes process to attach your template to the CMS. Obviously, some details will have to be tweaked within the forms but that is the topic of my next article.

Let us begin by dissecting a basic Textpattern template:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="<txp:css />" type="text/css" media="screen" />
<title><txp:page_title /></title>
</head>
<body>

This can be easily recognized as a basic HTML header. The only differences are the inclusion of the <txp:css /> tag to pull in the CSS from Textpattern, and the <txp:page_title /> tag which outputs a different tag based on the current location and attributes specified within the tag itself. The most comprehensive tag listing and description can be found at the wonderful Textbook.


<div id="container">
<!-- head -->
<div id="head">
<h1><txp:link_to_home><txp:sitename /></txp:link_to_home></h1>
<h2><txp:site_slogan /></h2>
</div>

This is the next part in a basic HTML template, the site title and slogan. Again, the tags are very intuitive due to their structure and naming. For example, creating a link to the home page involves simply wrapping the <txp:sitename /> tag, which outputs the Site Name from the Admin panel, in the <txp:link_to_home> tag, which creates the anchor and link.


<!-- sidebar -->
<div id="sidebar">
<txp:linklist wraptag="p" />
<txp:search_input label="Search" wraptag="p" />
<txp:popup type="c" label="Browse" wraptag="p" />
<p><txp:feed_link label="RSS" /> / <txp:feed_link label="Atom" flavor="atom" /></p>
<p><img src="textpattern/v5txp_img/v5txp_slug105x45.gif" alt="textpattern" /></p>
</div>

This part is a sidebar which includes the basic blog features such as a search form and category list. You do not have to worry about remembering or being able to manually create these tags because there are much more descriptive generators for the most useful tags.


<!-- center -->
<div id="content">
<txp:article />
<txp:if_individual_article>
<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_individual_article>
</div>
<!-- footer -->
</div>
</body>
</html>

This is where the content is called to action. Again, it is all controlled by a very simple yet powerful tag, in this case, <txp:article />. This tag would output any and all content according to the “default” article form. This example is simply showing a basic page template; a more practical layout would probably specify a limit as well as a list form or other specialty. Also, a much wider tag, <txp:article_custom /> gives you much more power over what articles to output.

The next part of this code snippet creates a link to a previous and, if available, next article. However, if you look closely, you will see that the links (following the format of our Site Name above) are enclosed within the conditional tag <txp:if_individual_article>. This means that only on pages where an article is outputted individually will these links appear.

I realize that this article transitioned to discussing tags, but that is essentially what the templating system involves. All you have to do is create an HTML template according to your usual methods and then be comfortable enough with the tags to attach your design to the CMS. Obviously, I cannot describe all of Textpattern’s tags, but what I have tried to do is show how wonderfully easy they are to implement.

Here is my feed if you would like to keep track of the series.

  1. AJ

    Dec 8, 07:27

    Great series, and a nice description of the tags. I’ll have to take a serious look at TextPattern now.

  2. Dave

    Dec 10, 15:43

    Wow, I’ve been using textpattern for a while now and I didn’t even realise it’s full potential.
    I’m gonna have a serious look at my structure now.

  3. Thame

    Dec 10, 18:55

    Dave:

    I discover new things about Textpattern every day, it really is an amazing CMS.

Add Your Thoughts

Textile Tips

  • _emphasis_
  • *strong*
  • "link text":http://link.url
  • ??citation??
  • @code@

Subscribe

Forum

Charity of the Month

Recent Comments

9rules Members

Academics Blog Top Sites

Sponsored Ads

Links

Buzzword Hell - The condemned ones include: "GYM Free", "Folksonomy" and "Social Networking"

Performancing Firefox Extension - A Firefox extension that allows you to write to your blog from within the browser. If you use Textpattern, you'll need the XML-RPC.

FACE - Faruk's Animated CSS Enhancements.

ExpressionEngine - pMachine has released a "core" version of EE with limited features and a nice pricetag: free. I might have to try it out.

Javascript Image Resizing - Smooth. Apperently, this is what iPhoto does...I really want a Mac.