Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-08-23 20:17:41

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

How do I change Category template? Or is it possible?

What I’m trying to acheive is on my site <a href=“http://www.kentuckygolfing.com”>Kentucky Golfing</a> you can see where I’ve got three test articles. They each have an attribute which I’ve got labeled “Filed in:” and then the corresponding category. Each category name is linked so the when clicked it takes you to all articles with that corresponding category. If you click on one of the category names now, it takes you to the default template (or same template as the homepage) with all of the articles that are in that category. I’d just like to change the template, because I don’t want everything on the homepage to show up when one of those categories are clicked.

Any way to do this?

Offline

#2 2006-08-23 20:40:16

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: How do I change Category template? Or is it possible?

You’ve got two options:

  1. Use if_category on the default template to change the template for categories. EX: <txp:if_category>[...]<txp:else />[for the homepage and site search</txp:if_category>.
  2. The much less involved way is to consrtuct your category links as such: http://site.com/section/?c=category. This will use the categorie’s section template. <a href="<txp:site_url /><txp:section />?c=<txp:category1 />"><txp:category1 title="1" /></a>

Offline

#3 2006-08-23 22:01:46

practical
New Member
From: seattle
Registered: 2006-08-23
Posts: 3
Website

Re: How do I change Category template? Or is it possible?

I stumbled upon this post after searching for “links section.”
I’m trying to organize my links page by category instead of just a block of text how it is now (www.practicalwestcoast.com/blog).
I think you’re offering advice, but would you mind elaborating? I could use the help.
I want my links to show up by category, i.e. food, clothing, projects, etc…
K

Offline

#4 2006-08-24 01:23:17

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Re: How do I change Category template? Or is it possible?

deldindesign wrote:

You’ve got two options:
<br />
bq. # Use if_category on the default template to change the template for categories. EX: <txp:if_category>[...]<txp:else />[for the bq.homepage and site search</txp:if_category>.
bq.# The much less involved way is to consrtuct your category links as such: http://site.com/section/?c=category. This will use the bq.categorie’s section template. <a href="<txp:site_url /><txp:section />?c=<txp:category1 />"><txp:category1 title="1" /></a>

Hi, I’m not so great with conditional tags. Seems I always muck something up. So that for me is going to be second choice in this matter. So, if I’m using your second suggestion, I’m somewhat confused. How do I set up my “category section template”? you said that if I construct my links that way I could use the category section template, and I’m confused on how to set that template up?

Last edited by deronsizemore (2006-08-24 01:24:36)

Offline

#5 2006-08-24 01:47:11

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: How do I change Category template? Or is it possible?

http://www.kentuckygolfing.com/article/?c=equipment

I don’t know what your page template for the article section looks like, but you could try something like this:

<pre>
&lt;txp:if_article_list&gt; &lt;txp:if_category&gt; &lt;p&gt;You are browsing &lt;txp:category1 title=“1” /&gt; &lt;txp:else /&gt; &lt;p&gt;Homepage stuff&lt;/p&gt; &lt;/txp:if_category&gt; &lt;txp:if_search&gt; &lt;p&gt;Search results&lt;/p&gt; &lt;/txp:if_search&gt; //now display the article list, regardless of category &lt;txp:article form=“article” limit=“999” /&gt;
&lt;txp:else /&gt; //single article &lt;txp:article form=“article” /&gt;
&lt;/txp:if_article_list&gt;
</pre>

form: article

To save on forms, you can use the if_article_list and if_individual_article conditionals with or without the txp:else statement.

<pre>
&lt;txp:if_article_list&gt; &lt;h3&gt;&lt;a href=”&lt;txp:permlink /&gt;”&gt;&lt;txp:title /&gt;&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Filed under &lt;a href=”&lt;txp:site_url /&gt;&lt;txp:section /&gt;?c=&lt;txp:category1 /&gt;”&gt;&lt;txp:category1 title=“y” /&gt;&lt;/a&gt; and &lt;a href=”&lt;txp:site_url /&gt;&lt;txp:section /&gt;?c=&lt;txp:category2 /&gt;”&gt;&lt;txp:category2 title=“y” /&gt;&lt;/a&gt; &lt;/p&gt; &lt;txp:excerpt /&gt;
&lt;txp:else /&gt; //when we have a single article &lt;h2&gt;&lt;txp:title /&gt;&lt;/h3&gt; &lt;p&gt;Filed under &lt;a href=”&lt;txp:site_url /&gt;&lt;txp:section /&gt;?c=&lt;txp:category1 /&gt;”&gt;&lt;txp:category1 title=“y” /&gt;&lt;/a&gt; and &lt;a href=”&lt;txp:site_url /&gt;&lt;txp:section /&gt;?c=&lt;txp:category2 /&gt;”&gt;&lt;txp:category2 title=“y” /&gt;&lt;/a&gt; &lt;/p&gt; &lt;txp:body /&gt;
&lt;/txp:if_article_list&gt;
</pre>

Offline

#6 2006-08-24 02:33:27

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Re: How do I change Category template? Or is it possible?

Thank you for taking the time to write all that out for me! I think I kinda see what you’re doing there. I don’t know why I have such a hard time with conditionals, but I do. I’ll get there eventually I guess. But, with my site, lets say I wanted to change the middle content area on my site after someone clicks on one of the categories (the recent pictures, recent posts, recent forum topics, etc). Essentially all I would need to do is (would I need the txp:if_article_list for the middle content? I get confused on when I need what tags:

<code>
<txp:if_article_list> <txp:if_category> <txp:cbs_category_list /> </txp:if_category> <txp:else /> <div id=“middlecontent”>
<div>
<txp:output_form form=“site_search” />
</div>

<div>
<h2>Recent Pictures</h2>
<txp:wet_thumbfilter section=“courses” limit=“4” wraptag=“ul” break=“li” />
</div>

<div>
<h2>Featured Course</h2>
<txp:output_form form=“featured_course” />
</div>

<div id=“recentposts”>
<h2>Recent Posts</h2>
<txp:article_custom form=“recent_posts” offset=“3”/>
<p class=“more_articles”><a href=”/archives”>More Articles</a></p>
</div>

<div id=“recentforumtopics”>
<h2>Recent Forum Topics</h2>
<ul>
<li><a href=”#”>Need to get rid of my wicked slice…can anyone help?</a></li>
<li><a href=”#”>What is the best Course in the State?</a></li>
<li><a href=”#”>I want to play Valhalla! How do I get on?</a></li>
<li><a href=”#”>Best teachers in the state? </a></li>
<li><a href=”#”>Need a ruling on a plugged ball on the green</a></li>
</ul>
<p class=“joinforums”><a href=”#”>JOIN THE FORUM NOW!</a></p>
</div>
</div>
</txp:if_article_list>
</code>

Last edited by deronsizemore (2006-08-24 02:35:12)

Offline

#7 2006-08-24 04:23:54

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: How do I change Category template? Or is it possible?

Hey Deron,

If you’re using rss_unlimited_categories with the site, you can make the category list use any section you wish.

Offline

#8 2006-08-24 14:31:05

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Re: How do I change Category template? Or is it possible?

Hey Egor, long time no see!

Hmmm…I do have that plugin installed but didn’t know it could do that until now. So to accomplish this, if I use this code:

<code>
linktosection
The section used for category links.
Default: ‘article’
Example: linktosection=‘10’
</code>
<br />

Where it has “linktosection=“10” I could just use say, “category” instead of “10”? Or do I need a numerical value there instead of the actual section name I want to use for the template?

Last edited by deronsizemore (2006-08-24 14:39:29)

Offline

#9 2006-08-25 05:19:12

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: How do I change Category template? Or is it possible?

You can specify the name, Deron.

Offline

#10 2006-08-25 11:34:08

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Re: How do I change Category template? Or is it possible?

Thanks! I appreciate the help guys

Offline

Board footer

Powered by FluxBB