Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-01-12 02:05:27

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

[howto] Using Forms to Simplify Site Administration

I’m posting this example/how to at the request of masmith as he thought it might be useful to some in the community.

When I used to design flat sites with Dreamweaver, I used templates a lot to cut down on redundant work, I also started using server-side includes for a while. When I started building sites with TXP I quickly learned to make extensive use of forms on a single ‘default’ page to acheive the same goal of making sites easier to manage.

One approach that I used a lot was this one. I’d make misc. forms to contain almost anything that I wanted to reuse. Section-specific stuff, navigation elements that would appear in articles, stuff that goes in sidebars, etc…

That worked great from an administrative perspective. I’d name the forms with a prefix based on the usage to keep everything organized like ‘page-breadcrumb’, ‘section-about’ or ‘header-scripts’. Then on my ‘default’ page I’d make calls to those forms and use conditionals inside section forms call/present specific content and structure.

Method One

A portion of the page might look like this

<div id="content">
  <txp:output_form form="section-home"/>
  <txp:output_form form="section-about"/>
  <txp:output_form form="section-blog"/>
</div>

The ‘section-contact’ might look like this:

<txp:if_section name="contact">
  <txp:image id="2152" />
  <txp:article_custom id="25" form="article-promo"/>
  <div id="emailForm">
    <txp:zem_contact to="mail@tld.com" copysender="yes" form="page-sidebar-email" />
  </div>
</txp:if_section>

While the ‘section-about’ might look like this:

<txp:if_section name="about">
  <txp:article form="article-promo" limit="3" sortdir="asc" />
</txp:if_section>

And the ‘section-gallery’ might look like this:

<txp:if_section name="contact">
 <txp:rss_thumbpop mode="float" orderby="date asc" showfullalt="1" showfullcaption="1" showcaption="0" showalt="0" jpop="1" showfullcaption="1"  cols="500" />
<txp:if_section name="contact">

That all works pretty well, until you start building bigger sites and the number of DB queries start slowing down your site. What to do… I liked the simplicity and organization of that method from an administratin perspective, but I didn’t like 60+ queries. That lead me to try another method…

Method Two

TXP selects a page, and style for each section, so I assume it’s like a free database query (perhaps this is not the way it really works). So I decided to use section-specific pages, but in a way that allows me not to have to edit the stuff on the page that is going to be the same every time, using two forms ‘page-header’ and ‘page-footer’ containing all of my basic page up to the if_section tags for the former and after the last if-sectin tag for the latter.

So a page called ‘contact’ might look like this:

<txp:output_form form="page-header"/>

  <txp:image id="2152" />
  <txp:article_custom id="25" form="article-promo"/>
  <div id="emailForm">
    <txp:zem_contact to="mail@tld.com" copysender="yes" form="page-sidebar-email" />
  </div>

<txp:output_form form="page-footer"/>

Note the omission of the <txp:if_section /> tag and resulting query.

So far this seems to speed sites up a bit, and keep them relatively simple to maintain.

I’d like to see other people’s tips on how to simplify site maintennance with TXP.

I don’t know. This is probably how smart people build TXP sites by default, however, it took me an interesting journey to get to this approach. Perhaps it will save someone else a long, strange trip.

Cheers.

Last edited by mrdale (2008-01-10 18:34:55)

Offline

#2 2007-01-12 03:07:04

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [howto] Using Forms to Simplify Site Administration

Well, thanks for posting all that @mrdale.
I’m pretty much doing the same as you describe.

I think in any case, you will get to the point, where you reach two basic barriers.

  1. Difficulties in maintaining and understanding the consequences of conditional clauses in page templates ( If forms sections and conditional plugins add up, especially when combined with category and individaul clauses )
  2. Difficulties in maintaining and finding forms.

I am Building a Gallery Site right now, and the forms that are in the Install are 102.
Finding the correct Form and knowing which one is used where, can be a tricky task.

Here’s some tricks, that I use sometimes:

  • Instead of commenting stuff out and in ( in case there are too many conditionals ), I branch out and create a new page
    and assign it to the section, that I am working on. This is easier and helps to understand the conditional contexts.
  • Instead of creating new forms, I comment blocks in and out in the same forms.
  • Special naming convention:
    • The first three digits, carry the name of the template name or get a creator index, if you like.
      (This helps to distinguish them from the default forms and keep them sorted separate for each form category in the backend)
      Here is an example of some img related article forms that are named in a way to indentify easily, what they are used for:

gen_img_more_cat_browse_1 article gen_img_more_cat_browse_1_cat_asc article gen_img_more_cat_browse_2 article gen_img_more_cat_browse_2_cat_asc article gen_img_more_cat_browse_3 article gen_img_more_cat_browse_3_cat_asc article gen_img_more_cat_browse_4 article gen_img_more_cat_browse_4_cat_asc article gen_img_more_cat_browse_5 article gen_img_more_cat_browse_5_cat_asc article

  • Output forms: Every single bit, that can be put in an output form, goes in an output form.
    (For instance, in your above example, I’d take the zem_contact stuff, and the article tag out as well, until everything is in the forms, except the page conditionals, whereever that is possible)
  • Navigating from Forms to pages, and pages to forms
    • This I do, using external Texteditor ( TM with the Textpattern Bundle). I created a special command, that allows me to go from any form attribute, to the relavant form with one single shorrtcut and Vice versa.
  • Comment Toggling: Instead of the normal coment Toggling I changed the comment toggling to use anc_hide instead.
    ( That makes it easier, still to leave some stuff in , in case a local dump get’s moved to a Live Server, without exposing the stuff on the front end )
  • And of course, there is mcw_templates

( my 5 cents )

regards, marios

Last edited by marios (2007-01-12 03:10:47)


⌃ ⇧ < ⌃ ⇧ >

Offline

#3 2007-01-12 03:09:18

DigitalRealm
Member
From: Greenville, SC
Registered: 2006-07-22
Posts: 139
Website

Re: [howto] Using Forms to Simplify Site Administration

When I built my first few TXP driven sites, I broke everything up into forms, as it seemed to be the best way of going about things. This was pretty easy to maintain but quickly built up to 20-30+ forms that I used for a site. I realized that (out of my own stupidity) I was duplicating code in a lot of places that I did not need to.

Now, I build things totally different. Now, I build a form for each “chunk” of the site. So I will have a form for like header, main content, sidebar, footer, navigation. Inside of each of those forms, I use the ob1_if_section plugin to display content based on the section where it is needed.

I will then build smaller forms for specific things such as a contact form, image gallery, etc.

This may not be the best or most economical way to do it, but it simply works better for me and I can maintain things far better.

Offline

#4 2007-01-12 06:37:51

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,324
Website Mastodon

Re: [howto] Using Forms to Simplify Site Administration

mrdale wrote:

Note the omission of the <txp:if_section /> tag and resulting query.

if_section comes at no db query cost but uses a global variable already set during URL decoding – a code branch you cannot avoid with either template structure. So from a performance point of view, both template building method are created approximately equal. They roughly differ by the negligible cost of one function call.

Offline

#5 2007-01-12 08:25:07

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

Re: [howto] Using Forms to Simplify Site Administration

wet says:

They roughly differ by the negligible cost of one function call.

Ok, I knew someone smarter would chime in… but how about the output_form call. multiply that a few times…

Last edited by mrdale (2007-01-12 08:27:46)

Offline

#6 2007-01-12 15:29:26

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [howto] Using Forms to Simplify Site Administration

DigitalRealm wrote:

[…] I use the ob1_if_section plugin to display content based on the section where it is needed.

Why do you use a plug-in and not the built-in txp:if_section conditional tag?


About this thread, it’s great to know different ways each one is working. I have opened a similar topic long time ago.

I used to try to do everything with minimal form qty, a lot of conditionals in forms and one page template and many section conditionals.
But I think working that way usually makes it hard to mantain a site and, also, working that way isn’t the most flexible option.

Also, I have thinked about the Ultimate Default Form by using txp:if_article_section.
The idea was to manage practically any article form by using the default form and few conditionals.

Now, I switched to work with one page template per section (sometimes, I share a page template between 2 or more sections, if there is no need (or minimal need) of conditionals.
I prefer to create more page templates and few more forms than messing with complex conditionals.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2007-01-12 17:50:47

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

Re: [howto] Using Forms to Simplify Site Administration

Idea: TXP Live Examples Site.

I always learn more when I can see other people’s TXP code and the resulting pages. after talking with maSmith, he seems to feel the same way.

So, would anyone be interested in a dedicated “TXP Live Examples site”? I might be interested in maintaining it if there were enough interest, and if it wouldn’t divert energies from this forum and the other excellent TXP resource sites (you know who you are). Certainly don’t want to cannibalize mindshare.

I picture a user being able to log in and see TXP code, check out the front-end, etc and hopefully learn best-practices more quickly by trying stuff out. I also think that it would provide a live repository for those who’ve figured stuff out and want to share ideas in a way that exposes the back end…

So what do you think? Let me know if you think this is a useful idea… If so I’ll start a new topic.


Proposed Framework

  1. Each user gets a section(s) to explore a specific idea, with their user name as a prefix to the section name, eg. if I want to show how to build a client section on a site, I call it ‘mrdale-clients’.
  2. Each user would name anything they create (pages,forms,styles) with a username prefix, eg. a form containing a ‘client-login’ would be called ‘mrdale-clients-login’ and a page would be called ‘mrdale-clients’
  3. Only the moderator would have ftp/database access, would approve new accounts, etc.
  4. Everything would be backed up daily. (Files and DBs) and rolled back a day if anything goes wrong
  5. Each section should have at least one article describing what’s going on.
  6. Comments would be switched on to encourage questions and answers feedback, and better methods etc.

Offline

#8 2007-01-12 21:13:51

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [howto] Using Forms to Simplify Site Administration

Sounds like a good Idea. I’d like to see this happen, really :))

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#9 2007-01-12 22:18:07

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: [howto] Using Forms to Simplify Site Administration

I second this one. Seems like a great idea!


Prrrrrrrr

Offline

#10 2007-01-13 01:56:28

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [howto] Using Forms to Simplify Site Administration

The idea is to port this forum to the WIKI. I won’t comment on whether it should be in the WIKI or in a live examples site, only that I’d be happy to see this forum’s contents ported somewhere so I can get rid of it here. :)

Offline

#11 2007-01-13 02:02:29

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [howto] Using Forms to Simplify Site Administration

@mary, hasn’t been forgotten.

( But yes , you are right, there is still some jewellery to get ported over .)

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#12 2007-01-13 02:41:06

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

Re: [howto] Using Forms to Simplify Site Administration

>mary

Not sure if you’re joking around or not, but I had in mind something completely independent, and of a much simpler scope, for a live examples site. Almost no content beyond short explanations of what you are doing and how…

Please don’t port this forum to the wiki. Please… I dig this forum just the way it is, :)

Last edited by mrdale (2007-01-13 02:45:23)

Offline

Board footer

Powered by FluxBB