textpattern basics - part 2
Posted on March 2, 2006 at 4:03 pm By Ryan in Options Trading | DisclaimerIn my last article textpattern basics – part 1 I reviewed some of the basic concepts in textpattern. As promised, this article will dive a bit deeper into sections, and I’ll start to peel the onion on page forms.
Sections
First off – I’m going to give credit to Thame at
erratic wisdom and quote some of his tutorial. Then I’ll dive into my read on sections and try to elaborate a bit..
Textpattern Sections are by far the most misused aspect of Textpattern and I am often guilty of employing them when they are entirely unnecessary. Textpattern sections are strong content and presentation dividers and are powerful enough to create different blogs or web sites from the same installation.
Separate sections should only be used if you are trying to:
- Create ?static? pages ? Tutorial
- Create different ?blogs? with entirely different layouts and styles
- Manage archives
Sections should not be used solely for content division; there are categories for that purpose as well as other external tagging services
erratic wisdom: Textpattern Sections
I think that pretty much puts sums up what sections are. They are your first line of content separation, and should by used for that and that alone. Sections create “mini websites”. They are not just for “other content” – use a category for that! Sections allow you to create complete and totally different areas of your website. Take for example how I employed them here at ryanbarr.com. I have 10 sections—ten sections you might say… let me run them down.
- about – basically my about page. I don’t want content from there to be syndicated and I don’t want it on the front page.
- archivescat – this is for the archives page by category. I’m using a section because it allows flexibility to re-style it if needed and provides a solid division from other content. I’ll dive into this a bit more when talking about forms later in the series
- archivesmonth – see archivescat; but monthly
- article – this is were all of my “articles” go. anything that is regular content to the website gets dropped in this section.
- contact – the contact form. It has its own page due to the different layout of the page
- disclaimer – my disclaimer. I added this because I started to talk about investing and options and wanted to cover my butt. Again, this isn’t syndicated but you can search it.
- family – my wife own little section
Okay, not really. This section is a bit like article, but its specifically for our “family” stuff. The family content goes here because we always have the most recent family article on the home page, and because eventually if we want to style it differently we can. - links – for the links – again this section is used to change the output form used
- pictures – all of our photo galleries use the pictures section. The content for these is substantially different and the layout is totally different than a regular article. I have pictures associated and all of that good stuff. So a new section was required.
- search – again, just like the archives pages, search has its own layout so I gave it a section.
As you can see, most of these are pretty straight forward. Some come from the design I had up by Stuart, and some are due to my own hacking and customization. I think that generally each one is required to get the feel I was looking for. Notice that there is not an investing section, or a wedding pictures section or anything like that. All of that content is categorized using categories not sections. The only slight exception to this rule is the family category; however, those articles are treated differently and are not in with the regular article lists. Because of those differences, I chose a new section.
In my list of sections, I referred to syndication, homepage, search and some other stuff. Basically, as of textpattern 4.0.3 there are eight options that you can setup for each section. They are as follows:
- Section name: The name of the section – used in your code and in the admin gui.
- Section title: The title used for display purposes
- Uses page: What “page form” to use when in this section. More on this later
- Uses style: What “style” to use when in this section. Again, more later
- Selected by default?: Convenience feature for the admin gui
- On front page?: Should content from this section show up when on the “front page” or in the default section
- Syndicate?: Should articles in this section show up in your RSS or Atom feeds
- Include in site search?: Should these articles be searchable
Some of these items, like name and title are used in code. Some define outputs and some define where content goes… If you have different needs for your content, then you probably need different sections!
So, when your actually writing code – how do you handle sections… First off textpattern comes with a few out of the box tags that are helpful.
<txp:if_section name=”[section name here]“> - Determine if we are in a section.
<txp:page_title /> - The title of this section
<txp:if_article_section /> - Conditional output to be used in an article form.
<txp:section_list /> - Shows a list of sections (navigation anyone??)
And to make it even better, I like to use some of the great plugin’s at rDS and Johan Nilsson to enhance what you can do with sections; take a look at glx_if and ob1_title. If those won’t fit what your looking to do, don’t’ forget the textpattern resources website!
Page Forms
Well, this article has already become quite long, so I’ll just “start” to peel the onion on this and go into more detail in the next article. I view page forms as your “starting” point for display. Each section has an associated page form – and textpattern installs three by default.
- default – the default form – used by most sections
- archive – used by articles (in the default install)
- error_default – used for reporting error pages
Each of these forms allows you to define how the page should be displayed. The rules for where articles go, how links are handled and what not are all in this form. Remember that each section is associated to one page form, so in theory, you can have a page form for each section if you wanted to!
I’ll go into more detail in my next article. Let me know if you have any questions or comments, I’m always happy to discuss it. If your looking forward to the next article – grab my feed Thanks!
Tags: textpattern
Categories: Options Trading



No Responses to “textpattern basics - part 2”