Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Where is the Unwanted Category Link coming from?
I am trying to achieve this layout for a navigation module for a used car sales site that deals with a bunch of different car marques; many of the marques have only a single car in them while the others have multiple items. I need the Marque’s with single cars present to link directly to the car’s article at mysite.com/cars/the-single-car-in-the-marque while the marques with multiple cars present link to a category page.
Marques A to D | Marques E to H | Marques I to N | Marques O to X |
---|---|---|---|
A Marque A to D | A Marque E to H | A Marque I to N | A Marque O to X |
Another Marque A to D | Another Marque E to H | Another Marque I to N | Another Marque O to X |
This isn’t a new TXP user topic, it has come up at least twice before here and here. I leaned heavily on the wisdom and experience of Maniqui, Gocom, Els et al accumulated in there and came up with this:
<nav class="cf">
<txp:category_list wraptag="div" break="" parent="marques" exclude="marques" children="0" class="topcat">
<div class="intercat">
<h3><txp:category title="1" /></h3>
<txp:category_list parent='<txp:category/>' exclude='<txp:category/>' children='0' wraptag="ul" break="li">
<txp:category >
<txp:variable name="morethanone" value='<txp:article_custom category=''<txp:category />'' limit="1" offset="1" />' />
<txp:if_variable name="morethanone" value="">
<!-- Problem likely in this line --><txp:article_custom category='<txp:category />' limit="1" ><txp:permlink><txp:category link="0" title="1"/></txp:permlink></txp:article_custom>
<txp:else />
<txp:category title="1" />
</txp:if_variable>
</txp:category>
</txp:category_list>
</div>
</txp:category_list>
</nav>
This works well except and does the business, except when I look at the source code and see that the links to the ‘single car in the marque articles’ contain a link to the Category page AND to the individual article page.
<li>
<a href="http://mysite/cars/?c=Alfa-Romeo">
<a rel="bookmark" href="http://mysite.com/cars/alfa-villa-d-este">Alfa Romeo</a>
</a>
</li>
Fortunately only the link to the article appears, it was the last order given and HTML is generally a good soldier. However, I’m not happy about it. What can I do to eliminate the first link, the one to the category page?
Last edited by joebaich (2012-03-31 20:15:48)
Offline
#2 2012-03-31 22:19:01
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Where is the Unwanted Category Link coming from?
This should work:
<nav class="cf">
<txp:category_list wraptag="div" break="" parent="marques" exclude="marques" children="0" class="topcat">
<div class="intercat">
<h3><txp:category title="1" /></h3>
<txp:category_list parent='<txp:category/>' exclude='<txp:category/>' children='0' wraptag="ul" break="li">
<txp:variable name="morethanone" value='<txp:article_custom category=''<txp:category />'' limit="1" offset="1" />' />
<txp:if_variable name="morethanone" value="">
<!-- Problem likely in this line --><txp:article_custom category='<txp:category />' limit="1" ><txp:permlink><txp:category1 link="0" title="1"/></txp:permlink></txp:article_custom>
<txp:else />
<txp:category title="1" link="1" />
</txp:if_variable>
</txp:category_list>
</div>
</txp:category_list>
</nav>
I removed the <txp:category>
container tag, because what it does is turn everything inside the container into a link. Added link="1"
to the category tag in the else part, and changed the category tag inside the <txp:permlink>
to category1 (please change it if it should be category2).
Last edited by els (2012-03-31 22:40:42)
Offline
Re: Where is the Unwanted Category Link coming from?
Thank you Els, that was exactly the problem and all works as intended now. Of course, now that you pointed to the error, it seems blindingly obvious.
I am very grateful.
Offline