Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-04-08 22:13:28
- woy
- Member
- Registered: 2009-04-08
- Posts: 18
problem with combined section/category/article navigation
hello,
this is my first post on the forums. You guys do a great job. I didn’t find an answer to my current question so I have to post it and ask for help.
I’m currently using a multi-level navigation. Using sections for the first level, categories for the second and an article list for the third level. It works great so far, but when I navigate to an article, my article list vanishes and my categorylist looses it’s active state. I suppose that this happens because the category isn’t handed over to the url, when I open an article. Is there a way to do so?
My forms for the category-list:
[nav]
<txp:if_section name="produkte">
<txp:category_list wraptag="ul" form="lnav_build" class="left_col_nav" categories="uebersicht,Festphasen-Extraktionskartuschen,polare-Sorbentien,mittelpolare-sorbentien,unpolare-sorbentien,spezialitaeten,zubehoer" break="" />
</txp:if_section>
<txp:if_section name="bekolut">
</txp:if_section>
[nav_build]
<txp:if_different>
<li<txp:if_category name='<txp:category/>'> class="active"
<txp:if_individual_article> class="active"<txp:else/></txp:if_individual_article>
</txp:if_category>
<txp:category link="1" title="1"/></li>
</txp:if_different>
Thanks in advance,
Sebastian
(edited for better code display. -Els)
Last edited by woy (2009-05-25 10:28:38)
Offline
#2 2009-04-09 22:15:32
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: problem with combined section/category/article navigation
woy wrote:
Using sections for the first level, categories for the second and an article list for the third level. It works great so far, but when I navigate to an article, my article list vanishes
It’s hard to say why that happens without knowing what code you are using to display the article list.
and my categorylist looses it’s active state. I suppose that this happens because the category isn’t handed over to the url, when I open an article. Is there a way to do so?
Something like this might work (not tested), but I don’t think it can be used inside if_different. I also don’t think I understand why you need if_different here…
<li<txp:if_category name='<txp:category/>'> class="active"<txp:else />
<txp:if_individual_article><txp:if_article_category name='<txp:category />'> class="active"
</txp:if_article_category></txp:if_individual_article></txp:if_category>>
<txp:category link="1" title="1" /></li>
Offline
Re: problem with combined section/category/article navigation
Els’ strikes again with a succint and ingenious method – not tested it either but it looks promising.
I had a situation once before where more than one category is assigned to an article and the article needed to display the category that had previously been chosen (where one had come from). The only way I managed this was to save the last chosen category into a cookie using chs_cookie, then use the cookie for the link back to the category page (or you could use it as a conditional for class="active"
).
TXP Builders – finely-crafted code, design and txp
Offline
#4 2009-04-12 13:56:03
- woy
- Member
- Registered: 2009-04-08
- Posts: 18
Re: problem with combined section/category/article navigation
Wow Els! Incredible, it worked for the categories. Adding the <txp:if_different> was just a desperate try to get it fixed.
My article output:
<txp:if_category>
<txp:article_custom category='<txp:category/>' form="content_link" wraptag="ul" class="content_nav" >
</txp:article_custom>
</txp:if_category>
<li<txp:if_article_id> class=“active”</txp:if_article_id>><a href='<txp:permlink />'><txp:title /></a></li>
So I’ll try to adapt your model to the articles as well.
Thank you very much and enjoy the rest of the easter-weekend,
Sebastian
Last edited by woy (2009-04-12 14:01:50)
Offline
#5 2009-04-12 15:35:19
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: problem with combined section/category/article navigation
woy wrote:
when I navigate to an article, my article list vanishes
My article output:
<txp:if_category>
…
You are telling Txp to only display the article list when on a category page… Adding an if_individual_article tag should help.
Offline
#6 2009-04-12 16:04:16
- woy
- Member
- Registered: 2009-04-08
- Posts: 18
Re: problem with combined section/category/article navigation
Thanks again, Els. I’ve tried around for a while. but I don’t get it. When I replace <txp:if_category>, all articles are displayed, regardless which category they are assigned to.
Where exactly do I have to add the if_individual_article.
Els, do you have an amazon-wishlist oder something similar to say thank you?
Offline
#7 2009-04-12 17:58:26
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: problem with combined section/category/article navigation
woy wrote:
When I replace <txp:if_category>, all articles are displayed, regardless which category they are assigned to.
Ah, now I understand (I think). You want to show the article list on a category page, and on an individual article page, where the articles in the list should be in the same category as the individual article, am I right? In that case try this:
<txp:if_category>
<txp:article_custom category='<txp:category />' form="content_link" wraptag="ul" class="content_nav" />
</txp:if_category>
<txp:if_individual_article>
<txp:article_custom category='<txp:category1 />,<txp:category2 />' form="content_link" wraptag="ul" class="content_nav" />
</txp:if_individual_article>
If you’re only using category1, you can of course leave out ,<txp:category2 />
. Does this help?
Els, do you have an amazon-wishlist oder something similar to say thank you?
No. Just saying thank you will do, thank you :)
(edit: corrected stupid mix-up of single and container tags…)
Last edited by els (2009-04-13 22:06:05)
Offline
#8 2009-04-13 19:24:36
- woy
- Member
- Registered: 2009-04-08
- Posts: 18
Re: problem with combined section/category/article navigation
Mh, I dont’t get it running. I made some changes to my template at link:http://www.oakpark.de/work/bekolut/ —hope it makes it more obvious.
I use the categories as my product-categories. And I want only those articles (products) to be displayed, which are assigned to the corresponding category. The article list should be displayed also when I have navigated to an article in the current category. The first problem with the categories is solved since I implemented your first suggestion. I’ll again and hope it’s just a single line that has to be changed.
Thanks again,
Sebastian
Last edited by woy (2009-04-13 20:13:28)
Offline
#9 2009-04-13 20:59:02
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: problem with combined section/category/article navigation
woy wrote:
Mh, I dont’t get it running.
What exactly doesn’t work?
I made some changes to my template at link:http://www.oakpark.de/work/bekolut/ —hope it makes it more obvious.
All the links on that page are going to #
… I honestly don’t know how I’m supposed to see what isn’t working… Can you post a tag trace of a page that isn’t doing what you want? And please tell me what it doesn’t do that it’s supposed to do?
In theory, my code example should do what you asked for:
And I want only those articles (products) to be displayed, which are assigned to the corresponding category. The article list should be displayed also when I have navigated to an article in the current category.
Offline
#10 2009-04-13 21:25:02
- woy
- Member
- Registered: 2009-04-08
- Posts: 18
Re: problem with combined section/category/article navigation
<txp:output_form form="content_nav" />
[SQL (0,00011396408081055): select Form from txp_form where name='content_nav']
[Baustein: content_nav]
<txp:if_category>
[<txp:if_category>: true]
<txp:article_custom category='<txp:category />' form="content_link" wraptag="ul" class="content_nav" >
[attribute 'category']
<txp:category />
[/attribute]
[SQL (0,00048112869262695): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (Category1 IN ('polare-sorbentien') or Category2 IN ('polare-sorbentien')) order by Posted desc limit 0, 10]
[Artikel 10]
[Artikel 9]
</txp:article_custom>
</txp:if_category>
<txp:if_individual_article>
[<txp:if_individual_article>: false]
</txp:if_individual_article>
What doesn’t work is that textpattern doesn’t generate the article list. I wonder why there are two articles [Artikel 10] & [Artikel 9] in the tag trace.
Last edited by woy (2009-04-13 21:27:35)
Offline
#11 2009-04-13 22:09:15
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: problem with combined section/category/article navigation
Sebastian, I’m sorry! I just discovered a very stupid mistake in the code I posted above, please try the code example in this post again, I edited it.
Offline
#12 2009-04-13 22:25:57
- woy
- Member
- Registered: 2009-04-08
- Posts: 18
Re: problem with combined section/category/article navigation
Els, thanks once again. It works. I now just get all the articles in the list, after opening an article.
[Baustein: content_link]
<txp:if_article_id>
[<txp:if_article_id>: false]
</txp:if_article_id>
<txp:permlink />
<txp:title />
[Artikel 14]
[Baustein: content_link]
<txp:if_article_id>
[<txp:if_article_id>: false]
</txp:if_article_id>
<txp:permlink />
<txp:title />
[Artikel 13]
[Baustein: content_link]
<txp:if_article_id>
[<txp:if_article_id>: false]
</txp:if_article_id>
<txp:permlink />
<txp:title />
[Artikel 12]
[Baustein: content_link]
<txp:if_article_id>
[<txp:if_article_id>: false]
</txp:if_article_id>
<txp:permlink />
<txp:title />
[Artikel 11]
[Baustein: content_link]
<txp:if_article_id>
[<txp:if_article_id>: false]
</txp:if_article_id>
<txp:permlink />
<txp:title />
[Artikel 10]
[Baustein: content_link]
<txp:if_article_id>
[<txp:if_article_id>: true]
</txp:if_article_id>
<txp:permlink />
<txp:title />
[Artikel 9]
[Baustein: content_link]
<txp:if_article_id>
[<txp:if_article_id>: false]
</txp:if_article_id>
<txp:permlink />
<txp:title />
</txp:if_individual_article>
That’s what I get. Is there a way around to hide or skip all the articles where [<txp:if_article_id>: false] applies?
Offline