Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-27 11:23:23

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

multiple pages vs. conditionals for sections

I’m wondering what the best approach is to having different content/ forms/styles for different sections.
In the past I’ve used the different pages approach, thinking that using <if section> and such might make the page slower, but I’m not sure how much of a concern that would be.
I also find it easy to get lost within multiple conditionals, all of a sudden I can find myself with <if section>, <if search>, <if category> <if individual> and all nested within each other.

Thant being said, I can see how having it all in one place can be practical.

Any opinions? Pros, cons, preferences?


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#2 2009-04-27 11:50:32

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: multiple pages vs. conditionals for sections

My preference is for fewer pages. With lots of pages it is too easy (for me) to make an edit on one but then forget to make the same edit on one or more of the remaining pages. But you’re right about convoluted conditional logic, so I try to balance this. Some sections just have very different types of content and it works better to use separate pages.


Code is topiary

Offline

#3 2009-04-27 14:53:28

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: multiple pages vs. conditionals for sections

What I do is attempt the best of both worlds; I sandwich the specific content for each page between two forms that get called on every different page, ie “page-header” and “page-footer”. This way I only have to update most page elements once by editing those two files and I let TXPs section setting specify the page to use.

Works pretty well, so most of my pages look a bit like this…


<txp:output_form form="page-header" />
     We're in a section X which is...
     <txp:article form="section-x" time="any" />
</div><div id="sidebar"><!-- ........................... -->
     Sidebar stuff Unique to section X
<txp:output_form form="page-footer" />

Offline

#4 2009-04-27 15:30:08

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: multiple pages vs. conditionals for sections

Like J Soo, I prefer using as few pages as possible— but my conditional statements aren’t that complicated— especially thanks to Gocom’s awesome sixth-sense plugin that outputs a form for the section requested.

As a result, I have one 12-line default page that drives most of my sites, along with a two contingency pages for search and errors. This approach was inspired by Tim Van Damme, and I’ve found it immensely flexible.

Offline

#5 2009-04-27 15:44:02

gavnosis
Member
From: Milton Keynes, UK
Registered: 2005-03-12
Posts: 151
Website

Re: multiple pages vs. conditionals for sections

This is very interesting… So, a question for Johnstephens:

Is http://designop.us/ a single page which does some magic to display the slim header in the about section?

I’ve just downloaded Gocom’s plugin…

Offline

#6 2009-04-27 17:40:26

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: multiple pages vs. conditionals for sections

oooh, that plugin is interesting!


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#7 2009-04-27 18:04:22

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: multiple pages vs. conditionals for sections

So the plugin just does this?

<txp:output_form form='section_<txp:section/>' />

Last edited by mrdale (2009-04-27 18:05:29)

Offline

#8 2009-04-27 22:07:28

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: multiple pages vs. conditionals for sections

I also tend to use a minimum of pages, but I’ll separate out a section that is drastically different. For example, I’ll use the same page for all “static” sections, and then a different page for a blog section. Also sometimes a separate page for the homepage, if it will have a unique layout.

Last edited by nabrown78 (2009-04-27 22:07:48)

Offline

#9 2009-04-28 02:05:51

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: multiple pages vs. conditionals for sections

mrdale wrote:

So the plugin just does this?

<txp:output_form form='section_<txp:section/>' />

You can also specify a default form which will render if there is no form correlating to the section you’re in. Something like this:

<txp:variable name="has_section_form" value='<txp:output_form form='my-prefix_<txp:section />' />' />
<txp:if_variable name="has_section_form" value="">
<txp:output_form form="my-prefix_main" />
<txp:else />
<txp:output_form form='my-prefix_<txp:section />' />
</txp:if_variable>

And that is all contained in a tag like this:

<txp:rah_output_section_form prefix="my-prefix_" default="my-prefix_main" />

I’d never thought of doing it with Textpattern’s native tags before, but that wasn’t so hard. It can also output a form based on category instead of section, by changing the type attribute, but I’ve never used that bit.

Thank you Mr. Dale for challenging me to see the plugin’s power in TXP itself!

gavnosis wrote:

Is Design Opus a single page which does some magic to display the slim header in the about section?

That’s just CSS— I gave the body tag a class attribute like so:

<body class="<txp:section />">

…which allows me to assign different styles to body.default than body.is, etc. I have some conditionals for error messages and other stuff too.

My stylesheet isn’t as efficiently written as it could be, but I’ll worry about that after I fill in my portfolio section some.

Last edited by johnstephens (2009-04-28 04:48:22)

Offline

#10 2009-04-28 08:21:40

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: multiple pages vs. conditionals for sections

oooh, i haven’t yet gotten used to thinking in terms of nested tags, but that also opens up possibilities. In the end, i think I’m gonna go with 2 pages: one for the homepage and some section, and one for the 2 sections that require a bit more specific markup. Seems like a good compromise.


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#11 2009-04-28 12:16:25

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: multiple pages vs. conditionals for sections

It seems to me the main question is, “Where do you want to do traffic control?” The sections page looks at the tickets your visitors bring (the URLs they request) and directs them to a specified page, like a courteous usher. If you prefer to do it yourself in your text editor, as I do, Textpattern has tags that make it easy to do so. ;)

Offline

Board footer

Powered by FluxBB