Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2005-12-21 09:14:32
- marknumberm
- Member
- From: Minneapolis
- Registered: 2005-11-29
- Posts: 46
Call separate forms for lists and indivdual articles?
Hi, Gang.
I’m creating a new project with TXP and I’m really excited about it.
But I can’t get this code to work; it’s not using the “Single” form for individual articles:
<code><txp:if_article_list>
<txp:article_custom form=“default” limit=“9999” sortby=“Custom_1, Custom_2, Custom_3” sortdir=“asc” />
</txp:if_article_list>
<txp:if_individual_article>
<txp:article form=“Single” />
</txp:if_individual_article></code>
What I read in TextBook about forms and in Textpattern Resources about using both the article_custom and the article tags led me to believe this set up would work.
But so far individual articles are still getting the default form, which I have set up to show only an excerpt of the post.
Is there another method I should use to call separate forms for lists and indivdual articles?
Offline
Re: Call separate forms for lists and indivdual articles?
What you have should work though it could be slightly simplified:-
<code>
<txp:if_article_list>
<txp:article_custom limit=“9999” sortby=“Custom_1,Custom_2,Custom_3” sortdir=“asc” />
<txp:else />
<txp:article form=“Single” />
</txp:if_article_list></code>
<br />
<code><txp:else /></code> is a handy tag to remember and the “default” form is called by default so there is no need to specify it if that is what you want to use. I don’t think you should have gaps after the commas in the “sortby” list either.
<br />
Why isn’t it working? I’m wondering if you are calling articles from the “article” section. If you are then they are set in the “Sections” tab to use the archive page template for “individual_article” view so it is that page template that you need to apply the “Single” form to.
Last edited by thebombsite (2005-12-21 13:55:59)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#3 2005-12-21 15:24:06
- marknumberm
- Member
- From: Minneapolis
- Registered: 2005-11-29
- Posts: 46
Re: Call separate forms for lists and indivdual articles?
Great!
Your code is tighter and accomplishes the same thing, so I’m using it.
I swapped it into the archive page template and now everything’s working.
I wonder, though, why I wouldn’t want to simply go into the presentations > sections tab and set articles assigned to the “articles” section to use the default template. Maybe it doesn’t make any difference as long as I remember which sections use which template.
I guess that would allow me to save the archive template for some other purpose. But, on the third hand, it’s not as though I can’t just create more templates, so maybe it really doesn’t matter.
Offline
Re: Call separate forms for lists and indivdual articles?
Well you can do that if you want, it would be a more efficient use of the template and as you suggest, allow you to use the “archive” template for something else such as an archive, but you should remember that this will effectively separate the default section into a kind of “standalone” which isn’t a problem at all, but you should just remember that you have done it.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Call separate forms for lists and indivdual articles?
Hi marknumberm. I have done a quick read at your post and at Stuart suggestions.
I think you can simplify your code even more ():
<txp:article form="Single" listform="default" limit="9999" sortby="Custom_1,Custom_2,Custom_3" sortdir="asc" />
That means this whole sentence:
“If in article-list context, output an article list using form “default” (listform="default"
). Limit the list to 9999 articles. Sort by… blabla.
If in individual-article context, output the individual article using the form “Single” (form="Single"
).”
It’s like conditionals but without using conditionals!
That’s because txp:article
is context-sensitive. That means: the tag know if the context is article-list or individual-article. And then, it looks at form
and listform
attributes, to know which form to use in each case.
Txp:article_custom
is not context sensitive, and it doesnt support listform
attribute.
Last edited by maniqui (2005-12-22 04:50:53)
Offline
#6 2005-12-22 05:19:59
- marknumberm
- Member
- From: Minneapolis
- Registered: 2005-11-29
- Posts: 46
Re: Call separate forms for lists and indivdual articles?
Wow, that works too. Thanks!
But now I’m wondering if maybe the info on this page, which is referenced in TextBook and seems to be fairly popular, is a little out of date, or just misleading. It makes it sound as though every properly constructed textpattern page template should have both the <txp:article />
and <txp:article_custom />
tags. (At least that’s how I read it.)
Offline
Re: Call separate forms for lists and indivdual articles?
I think the article may be a little out of date, as you said.
I would reccomend you to read all the FAQs, particulary both this:
What does article_custom do?
Why aren’t the right articles showing up on my page?
Good luck!
Offline