Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Render 'article' section with different page templates
I’m having a small problem with a site. I’m trying to render items in the default ‘article’ section with two different page templates based on I suppose a URL parameter.
I can’t create another section and output the items with an article_custom tag because I want to preserve the ability to filter the displayed articles based on URL params (like pages or categories).
Any tips?
Offline
Re: Render 'article' section with different page templates
Had a similar problem with a site I am working on now. The people wanted more than one design in each section of the site. I solved it easily with if_ conditionals.
Not sure if this is what you want, but it does work. Basically, the logic is if we are in a main page, show one design (subcontent div), if we are in an individual page, split the divs left and right.
<txp:if_individual_article>
<div id="leftlarge">
<txp:article limit="1" />
</div>
<div id="rightsmall">
<txp:if_article_id id=22>
<ul class="smd_slimbox">
<txp:smd_slimbox category="side_adventure" limit="36" />
</ul>
<txp:output_form form="adventure" />
</txp:if_article_id>
<txp:if_article_id id=24>
<ul class="smd_slimbox">
<txp:smd_slimbox category="side_media" limit="36" />
</ul>
<txp:output_form form="media" />
</txp:if_article_id>
<div class="width420">
<h2 class="slashes white">Links///</h2>
<txp:linklist break="li" category="Links" sort="linksort asc" wraptag="ul" class="height200" />
<div class="slashbg"></div>
<!-- end width420 -->
</div>
<!-- end rightsmall -->
</div>
<txp:else />
<div id=subcontent>
<txp:if_article_list>
<txp:article form="main" />
</txp:if_article_list>
<!-- end subcontent -->
</div>
</txp:if_individual_article>
Offline
Re: Render 'article' section with different page templates
Hmmm, that didn’t work quite the way I expected, thanks for the tip though.
I guess it might help to describe why I need this. One of the templates is needed for displaying the articles normally and the second page template is actually outputting JSON so that a user can dynamically update the displayed articles in the normal template. However, for it to degrade gracefully, I’d like to be able to request the JSON template through JavaScript if it’s enabled or link to a regular page if it isn’t. That’s why I need to be able to pass filtering options through the URL for pagination and selecting categories.
Does that make sense? Am I going about it in a wrong way?
Offline
Re: Render 'article' section with different page templates
I suppose another avenue would be to somehow clone the article section such that anything posted to ‘article’ would also be posted to a new section ‘json’ which would have its own template specified. Anyone know if that might be possible?
Offline
Re: Render 'article' section with different page templates
Wish I could help but I don’t know anything about JSON….
Offline