How I Use Sections, Pages and Forms

Even though I tested out all my codes yesterday to make sure they worked before I posted them I messed up with the full secondary_default page. I said to use:

<txp:else />
<txp:article form="secondary"/>

However, as I found out today thanks to TWD I found out that it stopped working and the pages broke. Removing the offending code will fix the problem immediately. My apologies for the mistake, the code has been updated so if you used it then I’d recommend you update it.

This originally started out as a comment, but it quickly got out of control so I thought it best to bring over here. I’m going to show you how I set up my site using Pages, Forms and Sections.

However, making static pages is quite a hassle and I simply do not have the time at the moment to go through this long process of making article forms link to page templates and making page templates link to sections. sigh The preview-before-submitting rule may also be a bit confusing for some visitors..
Still Not Having Any Luck

This is by no means an attempt to get Enzo to switch over to Textpattern, that’s completely up to him. His post just inspired me to finally write up a post on how I manage my sections, pages and forms. I hope that this helps you decide on a blogging system, Enzo.

The best advice I can give you is don’t over-complicate things. You don’t need to create a unique set of pages and forms for each section, I have one Page and one article form that manages the about, you and domain sections and most of their content! The first thing you need to do is create a new article form called secondary_default (or whatever you want, it’s up to you). Remember that the form you’re replacing with this is the default form which controls the title, postmeta information and body of the page. I haven’t changed my secondary_default form since I created it, I simply stripped the title of permalinks and postmeta information resulting in this:

<h1><txp:title /></h1>
<txp:body />

That’s it. Really. It controls pretty much every single page that isn’t in the article section because I don’t need anything more than that for my subpages, who does? Well, you might, but it’s actually quite easy to control most (not all) of your subpages through one Page.

How? I use good old if_section and else tags:

<txp:if_section name="content">
<txp:article form="third_default" />
<txp:else />
<txp:article form="secondary_default" />
</txp:if_section>

What that does is, if the section name is content (you can specify more than one section. Ex.: about,content,domain,links), it will show the content using the article form third_default. If the section name isn’t content then it will show it using secondary_default. Let’s look at a real world example of it:

<txp:output_form form="header"/>

<div id="content">
<a name="startcontent" id="startcontent"></a>
<txp:if_section name="about"><txp:article id="2" limit=1 form="secondary"/></txp:if_section>
<txp:if_section name="you"><txp:article id="130" limit=1 form="secondary"/></txp:if_section>
<txp:if_section name="domain"><txp:article id="200" limit=1 form="secondary"/></txp:if_section>
</div>

<txp:if_section name="you">
<txp:output_form form="sidebar_content" />
<txp:else />
<txp:output_form form="secondary_sidebar" />
</txp:if_section>

<txp:output_form form="footer" />

I use id=”#” and limit to specify which article to show on the subpage, that allows me to put almost all of the content for each section into the section. For example: Instead of putting, oh say, my reviews in a generic section (such as site) or in their own section, I can put them in the section “you” and rest easy knowing that they won’t show up on the main page. That means that I only need the one Page to control the appearance of my content page and its child pages. You’ll notice that I only used one else tag specifying what to do if the section isn’t about, you or domain, you don’t need to specify it more than once. You may not be able to manage all of your pages like this, but you sure can lighten the load by combining things wherever you can.

On another note, you should probably go check out the latest edition of Fuse Magazine because it’s pretty awesome (especially Top 10 Resources: Firefox 3 Extensions).

If you liked this article then why not subscribe to the feed?

On older posts comments are usually closed, so if you'd like to discuss this topic with me then please contact me.

#1

THANK YOU. I am new to Textpattern and I am having serious problems trying to figure everything out, but now there’s at least one thing that works how I want it to work! :)

Cecelia Aug 1, 03:30 AM Permalink

#2

I’m sure it isn’t as complicated as it seems. I’d have to give it a little time to understand it, but right now I’m gonna have to say I’m with Brent. Expression Engine is a lot easier to use that what Textpattern seems to be. I’ll give ti a chance though. Thank you for posting this.

Regine Aug 3, 10:53 AM Permalink