Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Change the page template if within category
I have a page template assigned to a section, let’s say News. On the News landing page (section page) I have one design, but I would like to a different layout on the category pages.
For example, user goes to News and sees one layout, then clicks on World News (an article or a category within the News section), and a different layout is used.
I could use if_section or if_category conditionals for the style layout elements, but wondering if someone has come across a better/cleaner way.
Offline
Re: Change the page template if within category
Hi
Have you try to make link to a category by specifying a section (look at txp:category_list), you can make your link like this : yoursite.com/thesection/?c=category, then the category is viewed using template of thesection
Offline
Re: Change the page template if within category
Thanks Dragondz. I have what you describe in the current template, but wanted to change the design, hence the question. I solved it by using if_individual_article conditionals…..
Offline
Re: Change the page template if within category
Jonathan,
based on Dragondz reply, it seems you need to obtain the category with a get method. With some PHP lines into your <head> to call your css rules.
Last edited by Pat64 (2007-12-16 15:08:24)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Change the page template if within category
I use nested txp:output_form
-tags and txp:if_category
to do these shorts of things. Style changing could be done with <body id="<txp:category />"
or <txp:if_category><link rel="stylesheet" type="text/css" media="screen" href="<txp:site_url />textpattern/css.php?n=<txp:category />" /></txp:if_category>
Cheers!
Offline
Re: Change the page template if within category
Well, this is how I did it, might bring in some comments…
<!-- content -->
<div id="content">
<txp:if_individual_article>
<div id="leftlarge">
<txp:article limit="1" />
</div>
<div id="rightsmall">
<txp:if_article_id id=157>
<txp:output_form form="some_form" />
</txp:if_article_id>
</div>
<txp:else />
<div id="maincontent">
<div id="left"><txp:article status="sticky" form="sticky" limit=1 />
</div>
<div id="right">
<p>This is paragraph text</p>
</div>
<!-- end right --></div>
<!-- end maincontent -->
</div>
<div id=subcontent>
<txp:if_article_list>
<txp:article form="some_other_form" />
</txp:if_article_list>
<!-- end subcontent -->
</div>
</txp:if_individual_article>
<!-- end content -->
</div>
Offline