Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-06-24 14:36:50
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
When to use forms and when not
Unfortunately, even after having worked with Textpattern for a while, I still find the “model” of Txp highly confusing
http://textpattern.net/wiki/index.php?title=Textpattern_Semantic_Model
I’ve been reading the manual and everything about pages, forms etc a couple of times, but it is still very unclear what comes out when, or what to do to get out what I want.
However, I guess this is not the place to complain, and that’s not going to help me either, so I’ll just ask questions here ;)
So one question I have:
- do you have to use “forms”? Or would it be possible to only create sections and put all needed code in the pages?
- or, if I would not use forms, would I not be able to use all available “tags”?
Thanks!
Offline
Re: When to use forms and when not
Hi matthijs
I use forms like php includes
To explain
If you have 2 templates but all that goes into the <head>
and all that goes into the #footer
is always the same. You can use forms to store that information and when you want to change it, you will only need to do it once.
Forms are also excellent for custom content ie if you go for something like <txp:article_custom form="my_form">
Having said that most tags now have become container tags so you can add what you would in my_form
within the container
ie
<txp:article_custom>
content of the no longer needed form
</txp:article_custom>
Short but I hope it makes sense:)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: When to use forms and when not
hi matthijs,
1. No, you don’t have to use forms, but on some cases, it has its benefits, because you can reuse them on different pages or on different parts of the same page. Also, it helps to make your templates tidier.
Before TXP 4.0.7, there were already some tags that could be used as container tags, so instead of referring to a form, you could wrap the inner tags inside the container tag.
One big step forward on 4.0.7 was the ability to use txp:article
and txp:article_custom
as container tags too (before 4.0.7, the only way to render “inner” article tags (body, title, excerpt) was using a form).
2. Afaik, there should be no difference in calling a form or using the tags as container tags. So, you should be able to use all the same tags on both methods.
Edit: colak was faster
Last edited by maniqui (2009-06-24 14:50:23)
Offline
#4 2009-06-24 14:53:04
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
Re: When to use forms and when not
Hi Colak, thanks for your reply. I am very familiar with PHP (been developing in it for a couple of years now), so your comparison of forms to php includes makes sense. I kind of already understood that.
However, you mention two things which are still unclear to me:
Forms are also excellent for custom content ie if you go for something like <txp:article_custom form=“my_form”>
What do you mean with custom content?
Having said that most tags now have become container tags so you can add what you would in my_form within the container??
What do you mean with container tags? Someone else mentioned that term as well
[edit:] I also see your reply now maniqui, thanks for that.
I think the same question applies to your answer.
Last edited by matthijs (2009-06-24 14:55:35)
Offline
Re: When to use forms and when not
maniqui wrote:
2. Afaik, there should be no difference in calling a form or using the tags as container tags. So, you should be able to use all the same tags on both methods.
Using containers instead of forms is slightly faster – erm, the page is loaded faster and causes less server load. The fact is caused because the usage of form causes more DB queries (because we need to load the form from txp_form table when in container we don’t).
Offline
#6 2009-06-24 15:36:41
- matthijs
- Member
- Registered: 2008-12-15
- Posts: 32
Re: When to use forms and when not
Ok, to know that – as far as the txp tags them selves and their usage is concerned – there is no difference between having them in a “page” or a “form”, is good to know. That way, I don’t have to worry about forms, until I have something working as I want and I want to make a snippet of code re-usable.
I still have to figure out exactly what a container is. Is this a container?
<txp:if_category>
…
</txp:if_category>
by the way, as a side note: the fact that they are called “page” and “form” is a bit confusing already, I think. What is meant with “page” is a template. What is meant with “form” is partial template. And the normal meaning of form in web development is a form with fields to fill in and post, etc
Offline
#7 2009-06-24 15:40:31
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: When to use forms and when not
matthijs wrote:
What do you mean with container tags?
It has an opening and a closing tag that spans code, like a div tag.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: When to use forms and when not
matthijs wrote:
I still have to figure out exactly what a container is. Is this a container?
txp:article
can act both as a self-closing tag and as a container tag.
<txp:article form="my_form" /> <- self-closing tag
<txp:article>
<txp:title />
<txp:body />
</txp:article>
Conditionals (like if_category
) are also somewhat container tags.
by the way, as a side note: the fact that they are called “page” and “form” is a bit confusing already, I think. What is meant with “page” is a template. What is meant with “form” is partial template. And the normal meaning of form in web development is a form with fields to fill in and post, etc
I agree. “Page template” instead of just “page” and “block” instead of “form” could be a better nomenclature. In fact, in the Spanish translation, “Formularios“ (“forms”) has been changed to “Bloques” (“blocks”).
Offline
Re: When to use forms and when not
Gocom wrote:
Containers are not always faster than forms. That really depends on:Using containers instead of forms is slightly faster – erm, the page is loaded faster and causes less server load. The fact is caused because the usage of form causes more DB queries (because we need to load the form from txp_form table when in container we don’t).
- how much code is in the form, more specifically: how many tags and nesting levels are in the form. Huge nested constructs can increase parsing time more than the overhead caused by putting part of that code in a form.
- how often is the form actually loaded, instead of ignored due to conditional constructs. If you have a conditional construct that contains lots of (nested) code, in many cases the code that’s in the unused (false) part of the conditional still has to be parsed to execute the used (true) part of the conditional.
Because it can go either way, I’d simply use forms when that makes it easier to maintain your website.
Offline
Offline
Pages: 1