Do you sometimes just hate the amount of Textpattern conditionals and <txp:output_form /> tags, cases where you’re building different content for large amount of sections?

As we know, sometimes the page template just starts to look ugly mix of section based conditionals, or there is just too many templates. I hate many individual templates, because it causes too much work and individual editing. Want to add a tag there? The you must to do it for all templates, if you want it to come up on every page.

But when templates are bad, so are too many conditionals.

<txp:if_section name="xxx"> my section content </txp:if_section>

Yes, now it looks clean, but what about when we have 50 sections? Not so. But what about the great <txp:output_form /> tag? What about we make it automatic, so it outputs different form based on the section? It’s possible and easy with one (or couple) line of PHP:

<txp:php> echo output_form(array('form' => 's-'.section(array()))); </txp:php>

That simple line outputs misc Textpattern form for every section, well atleast if it is used in every sections template. It just simple calls form called s-SectionName, in example s-blog. It like builds <txp:output_form form="s-blog" />, but with out need of conditionals. And I use it for every Textpattern website I make. How simple is that.

For those who like more plugins, I have one: rah_output_section_form. It does everything this and even more with out you typing any simple PHP.

Have tips, tricks or feedback? Let @gocom on Twitter to know.