Textpattern : Pages and Sections
The two fundamental building blocks of Textpattern are pages and sections.
At its simplest, a Textpattern page is just the same as a static HTML page. It does, however, have the capacity to be much more than that.
Create a Static Website Using Textpattern
Textpattern works by using a database, and this is what gives it its power and versatility. But you aren’t compelled to take advantage of all the things a database can do. You can use Textpattern simply to display a static website if you want.
By learning how to convert a simple, static website into the Textpattern format, you will understand how the system’s building blocks work.
Static HTML to Textpattern
By converting a normal HTML page into a Textpattern page, and then creating a Textpattern section dedicated to that page, your original HTML page will become part of a database website.
This is how to do it:
- Go to Presentation, then Pages.
- Create a new page by going to the box labelled Copy page as. Give it a name and click Copy.
- Take a static HTML page and paste it over the code on the Textpattern page.
- Click Save. Textpattern will not remind you to save your work.
- Go to Sections.
- Create a new section by writing the name of the new page in the uppermost box, and clicking Create.
- Scroll down the Sections screen until you find the name of your new section. Match the section to the page you have just created, by selecting the name of the page from the drop–down list labelled Uses page. For now, don’t worry about any of the other options.
- Click Save. Again, Textpattern will not remind you to save your work.
How Pages and Sections Link Together
A section is the primary structural unit of a Textpattern website. Each item in a website’s main navigation menu will normally be a section.
The Textpattern page is a flexible template which contains the HTML code, the text, the links, and anything else that appears on the publicly–visible website.
The Textpattern section is what anchors the Textpattern page to the database.
An Entire Website Using Textpattern
You can convert a static HTML website into Textpattern very simply:
- Make each static HTML page into a Textpattern page.
- Create a Textpattern section for each page
Linking the Pages
The only adjustment that’s needed is to change the links between the various pages from the standard HTML format to Textpattern’s database–friendly format.
So a link to a contact page would need to be changed from, say:
go to our <a href="contact.html">contact page</a>
to this, if you are using messy URLs:
go to our <a href="/?s=contact">contact page</a>
or this, if your web host allows you to use clean URLs:
go to our <a href="/contact/">contact page</a>
The section name also appears in the URL:
You can select the type of URL that suits you by going to Admin then Preferences, and use the drop–down box by Permanent link mode:
The main Textpattern site contains information about clean and messy URLs.
Advantages and Disadvantages
Of course, using Textpattern simply to create a static website may not seem worth the bother. You have one extra level of complexity over a standard HTML website: the sections that are needed to attach the Textpattern pages to the database.
Nevertheless, there are good reasons why you may want to do this:
- You get to use clean URLs, if your web host meets certain requirements.
- You get to use a secure, spam–free contact form.
- Knowing how to create a static website with Textpattern is the first step in building a database website.
And a database website has many advantages over a static website. To create a database website using Textpattern, you need to know how to use Textpattern forms, which is what we will do next.
Continue with the next article: Textpattern Forms.
[This tutorial is part 2 of a series by Jeremy Bojczuk intended to introduce the Textpattern content management system to web designers who have no knowledge of PHP or databases.]
- The main Textpattern website: download the latest version
- Textpattern forum: advice and tutorials
- Textpattern manual: tag lists
- Textpattern resources: plug–ins
- Textpattern Solutions: book, also available as PDF
- Textgarden: Textpattern themes
- Nora Brown Design: basic tips
- Txp Tips: in–depth tips
- We Love Textpattern: gallery