Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How to display content from different sections using different forms?
Hello,
I am finally setting up my site (that has long been in the development…) in TXP, and here is a problem I encountered. I have basically two different types of posts, long articles and short links and bits (Tumblr style). They use different forms and I have separate sections (‘longs’ and ‘shorts’) to display them (I think it’s not possible to have them done in a single section from the start).
Now, I want to display these longs and shorts on a single page so that they’re mixed together (Daring Fireball style). I can pull them from both sections using article_custom tag, but this tag forces the content to be displayed with only a single form.
My question: how do I display content from diferent sections so that they retain the formatting from their respective sections (so that shorts are displayed with the shorts form, and the longs with the longs form)?
I would be very grateful for any hints.
cheers
yot
Offline
Re: How to display content from different sections using different forms?
Hi
you can create a new article form mixing both and use <txp:if_article_section> to output what you want like that
<txp:if_article_section name="longarticle">
here long article stuff
<txp:else />
here small article stuff
</txp:if_article_section>
Cheers
Offline
Re: How to display content from different sections using different forms?
Hi,
and thanks for the quick reply! What I want should (in the simplest case…) be done by something like this:
<txp:article_custom>
<txp:if_article_section name="shorts">
<txp:article_custom form="shorts" />
<txp:else />
<txp:article_custom form="longs" />
</txp:if_article_section>
</txp:article_custom>
But what it does instead is just lists all the content from both sections, first using form ‘shorts’ and then the same content again, but using form ‘longs’…
Any ideas? What do I do wrong?
cheers
yot
Offline
Re: How to display content from different sections using different forms?
yotiao wrote:
Any ideas? What do I do wrong?
You are calling article lists within articles. You don’t need to call <txp:article_custom/>
again from the article markup. If you do that, it will show the article list as the content of articles.
<txp:article_custom>
<txp:if_article_section name="shorts">
<!--
Article context tags here.
-->
<txp:title />
<txp:excerpt />
<txp:else />
<!--
Article context tags here.
-->
<txp:title />
<txp:body />
</txp:if_article_section>
</txp:article_custom>
Offline
Re: How to display content from different sections using different forms?
Oh, I know one thing that is wrong with the above code – I had to tell TXP the section explicitly for each custom_article tag I use. My full code looks like this now:
<txp:article_custom>
<txp:if_article_section name="shorts">
<txp:article_custom section="shorts" form="shorts" />
<txp:else />
<txp:if_article_section name="longs">
<txp:article_custom section="longs" form="default" />
</txp:if_article_section>
</txp:if_article_section>
</txp:article_custom>
Now it does almost what I want. It uses the correct formatting from the respective sections :-) but it also displays the content multiple times… It seems the loop displays all the articles from each section each time the if statement is true. So if I have 4 articles in the long section, it will display all 4 articles 4 times.
Hmm.
I’ll keep trying.
yot
Offline
Re: How to display content from different sections using different forms?
@Gocom
Excellent timing! Thanks a lot and I am going to try your solution now…
yot
Offline
Re: How to display content from different sections using different forms?
Gocom,
Dragondz
Oooooh, it works like a charm… Awesome.
Thanks a million!
yot
Offline
#8 2010-03-16 14:36:16
- sereal
- Member
- From: Indonesia
- Registered: 2010-02-18
- Posts: 55
Re: How to display content from different sections using different forms?
this post is very usefull for me, but it’s different situation I got here,
I can make my following tag to work very nicely
I use this in my page section to call single article in front page
<txp:article_custom limit="1" form="myArticle" section="myInfo" />
and this is the form I use to display the article
<txp:if_section name="myInfo">
<h1><txp:title /></h1>
<p>
[<txp:posted />] oleh <txp:author />
</p>
<txp:else />
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<txp:excerpt />
<p>
[<txp:posted />] oleh <txp:author /> | <txp:permlink>read more</txp:permlink>
</p>
</txp:if_section>
the above first tag I use limit=“1” to show 1 article in front page which is posted in myInfo section
I have a question here
- How to display only 1 article in myInfo section ?
please advise…
thank you
Last edited by sereal (2010-03-16 15:20:28)
$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?
Offline
Re: How to display content from different sections using different forms?
Hi sereal
in your page template(or form i dont know how you organize your code) you have a <txp:article /> tag, threr you may change the code like this:
<txp:if_section name="myinfo">
<txp:article limit="1" />
<txp:else />
<txp:article />
</txp:if_section>
Cheers
Offline
#10 2010-03-16 14:55:41
- sereal
- Member
- From: Indonesia
- Registered: 2010-02-18
- Posts: 55
Re: How to display content from different sections using different forms?
Hi Dragondz
I have tried that and can not make it work :(
still showing all posted articles in myInfo section
Last edited by sereal (2010-03-16 14:57:06)
$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?
Offline
Re: How to display content from different sections using different forms?
can you post your code to see what’s wrong.
Offline
#12 2010-03-16 15:57:45
- sereal
- Member
- From: Indonesia
- Registered: 2010-02-18
- Posts: 55
Re: How to display content from different sections using different forms?
code below is in the page template to call a single article in front page
<txp:article_custom limit="1" form="myArticle" section="myInfo" />
and this one below is myArticle form I use to display the article
I add article limit but no luck
<txp:if_section name="myInfo">
<txp:article limit="1" />
<h1><txp:title /></h1>
<p>
[<txp:posted />] oleh <txp:author />
</p>
<txp:else />
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<txp:excerpt />
<p>
[<txp:posted />] oleh <txp:author /> | <txp:permlink>read more</txp:permlink>
</p>
<txp:article />
</txp:if_section>
please advise
thank you
Last edited by sereal (2010-03-16 15:58:00)
$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?
Offline