Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
One Page, different content using forms
Hey guys, here’s my issue, I am trying to use just one page as my layout, then changing the content using forms. I’m running a review and news site so I don’t really want to have 26+ pages each with the layout coded into it… I’d rather just have that many forms, and one page which changes the form in the content area as needed.
Is this at all possible?
Offline
Re: One Page, different content using forms
Take a look at Tag basics, particularly Parsing tag attriubtes, and combine that knowledge with few tags such as output_form and section.
<txp:output_form form='content-<txp:section />' />
The other option is to split the template itself into few forms, so you don’t have to have much layout duplicated in your pages:
<txp:output_form form="header" />
<!-- Any section content here. -->
<txp:output_form form="footer" />
Last edited by Gocom (2013-08-02 20:10:29)
Offline
Re: One Page, different content using forms
Yes, I know how to show a form on the page, but not how to dynamically chnage it. Eg:
http://www.glaciergaming.co.uk/blog/reviews-t uses the same page as http://www.glaciergaming.co.uk/blog/reviews-a but they use different forms, one which shows reviews from one section, and the other uses a form from another section
Offline
Re: One Page, different content using forms
SPKuja wrote:
but they use different forms
Exactly what the presented snippet does. This one, remember:
<txp:output_form form='content-<txp:section />' />
Displays a section specific form: content-blog
for blog, content-about
for about section. Altho, if you simply want to list different set of articles with same layout, there are better ways than duplicating forms. For example, if you want to list reviews by letter, you could simply use a dynamically constructed article tag. As with dynamically changing forms, you will have various ways to implement it. There isn’t a shortage of ways to filter articles and construct context-sensitive lists.
If the section is named after the letter (a, b, c) and the letter is stored in an article custom field, you don’t have to do anything else than pass the name of the section to the custom field:
<txp:article_custom section="blog" letter='<txp:section />' />
Last edited by Gocom (2013-08-02 22:57:51)
Offline
Re: One Page, different content using forms
So how would I define which form is used? Would I inclued it in the URL? Sorry if I seem slow, I’m not too good with the whole form thing!
Offline
Re: One Page, different content using forms
What does the section tag return? The name of the section. If you want the form’s name be constructed from something else, see Tag Reference and pick something else. You could obviously also simply use conditional tags to display different content on different conditions.
Last edited by Gocom (2013-08-03 10:38:16)
Offline
Re: One Page, different content using forms
I don’t think I have explained my self too well.
What I need to know is, I want to have one page, with the layout, with the content section that loads up a form by default, so for example, when you go to the home page it will load up a form called “all_news”. Then, when you click on a link to show say news from the android section, it just changes the form from “all_news” to “android_news”.
A little like using PHP, the layout all stays the same but the content in the centre changes, as if I was using http://www.example.com/index.php?page=android_news.html
But obviously, the form that is displayed is changed. So if I need to edit the layout at all, I only have to do it once, and not for every single page on the site
Offline
Re: One Page, different content using forms
Would this work for you?
<txp:if_section name="">
<txp:hide>you are in the front page</txp:hide>
<txp:article form="all_news" />
</txp:if_section>
<txp:if_section name="android">
<txp:hide>you are in android section</txp:hide>
<txp:article form="android_news" />
</txp:if_section>
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: One Page, different content using forms
Actually, that would work really well. Thank you both for your help, I will give it a go :)
Edit:
Okay, so I have set my default page with the code:
<txp:if_section name="">
<txp:hide>you are in the front page</txp:hide>
<txp:article form="default" />
</txp:if_section>
<txp:if_section name="android">
<txp:hide>you are in android section</txp:hide>
<txp:article form="android" />
</txp:if_section>
Which loads of the default form nicely. When I visit http://glaciergaming.co.uk/blog/android it just loads the template without any thing in the content area. (I have set the android section to use the “default” page)
Last edited by SPKuja (2013-08-04 16:16:42)
Offline
Re: One Page, different content using forms
Hi Sam, Can you post the code you are using in the android form?
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: One Page, different content using forms
Sure, the code is:
<!-- articles display -->
<txp:article_custom limit="30" catagory="android"
offset='<txp:etc_offset pgcounter="page" pageby="30" />'
/><p>
<!-- pagination bar -->
<div align="center"><txp:etc_pagination
pages='<txp:etc_numpages catagory="android" pageby="30" />'
range="15"
pgcounter="page"
prev="Newer " next=" Older"
/></div>
Offline
#12 2013-08-05 15:25:32
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: One Page, different content using forms
You needed tags like <txp:body />
and <txp:title />
in your form, not another article tag.
Also (though not the cause of your current issue): The etc-prefixed tags belong on a page, not inside an article form, as contents of an article form are displayed once per article. Edit: Can’t say whether they’re useful for an article tag (the one you currently have on your page), only know them for article_custom.
Last edited by uli (2013-08-05 15:27:49)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline