Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2013-06-16 13:18:34
- Absolute
- New Member
- Registered: 2013-06-16
- Posts: 6
Category links (category1 category2) are broken
Hello,
Hope someone can help,
I have added the below code to my articles to provide links to articles matching the same category.
<txp:if_individual_article>
<div class="CategoryList">
<p>Categories:
<txp:category1 link="1" title="1" />
<txp:category2 link="1" title="1" />
</p>
</div>
</txp:if_individual_article>
The category links display right, and when I hover over them I get a decent looking url like:
website.com/category/cats
However when I click on the link, the page only displays the most recent article (regardless of what category its in), even though the url indicates I should be looking at all the “cat” articles.
Any suggestions?
Last edited by Absolute (2013-06-16 13:19:28)
Offline
Re: Category links (category1 category2) are broken
Hello, welcome to the forum.
website.com/category/cats
will display only articles (in cat
category) that belong to some “front page” section. So make sure that you have more than one such article. Also check if the limit
attribute of <txp:article />
is not set to 1.
Offline
#3 2013-06-16 14:31:50
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Category links (category1 category2) are broken
You probably only have a <txp:article_custom>
tag on the page template for section ‘default’, or you’re missing one or more conditional tags (e.g. <txp:if_category>
). Can you post the code on this page?
Offline
#4 2013-06-17 18:16:35
- Absolute
- New Member
- Registered: 2013-06-16
- Posts: 6
Re: Category links (category1 category2) are broken
Thank you for all your replies, what a brilliant response.
I am trying to add the hyperlinked categories to the single article pages.
I have a BLOG page template that only uses this line of code to pull in the indiviudal articles:
<txp:article form="SINGLE-ARTICLE" limit="5" listform="ARTICLE" pgonly="0" sort="Posted desc" status="4" />
The form SINGLE-ARTICLE has this code in it:
<h2><txp:title /></h2>
<txp:body />
<txp:if_individual_article>
<p>Categories:
<span class="SingleCategory"><txp:category1 title="1" /></span>
<span class="SingleCategory"><txp:category2 title="1" /></span>
</p>
</txp:if_individual_article>
Hope that helps.
Offline
#5 2013-06-17 18:19:39
- Absolute
- New Member
- Registered: 2013-06-16
- Posts: 6
Re: Category links (category1 category2) are broken
Sorry just to amend that last block of code, it should be:
<h2><txp:title /></h2>
<txp:body />
<txp:if_individual_article>
<p>Categories:
<span class="SingleCategory"><txp:category1 link="1" title="1" /></span>
<span class="SingleCategory"><txp:category2 link="1" title="1" /></span>
</p>
</txp:if_individual_article>
I removed the link=“1” part of the code for bug testing but it still doesnt work right :)
Offline
Re: Category links (category1 category2) are broken
A link like website.com/category/cats
lands on the page associated with the default
section. Are you sure the page used by the default
section is BLOG
? If yes, what is in the ARTICLE
(list)form?
Offline
#7 2013-06-17 20:10:36
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Category links (category1 category2) are broken
I think Oleg is right and your page template for section ‘blog’ is a different one than the one that is used by the front page. But there is another easy way to solve the problem: just add this_section="1"
to the category1 and category2 tags. Then the category pages will be displayed within section ‘blog’.
Offline
#8 2013-06-17 20:17:20
- Absolute
- New Member
- Registered: 2013-06-16
- Posts: 6
Re: Category links (category1 category2) are broken
You were all absolutely right. By adding this
section="blog"
my category links now work as hoped. Thank you all so much. Top forum!
Offline