Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2010-04-14 19:02:35
- bmwg
- Member
- Registered: 2010-04-06
- Posts: 39
Re: List of articles with current category
Ok, one more problem: each list gets filled with the right articles but as soon as I click on a link, the lists change. All that’s left is the link to the article I clicked and some text output saying that comments are disabled for this article (it gets output where the other list items are supposed to be). The article itself gets properly displayed at another div on the site though.
Offline
#14 2010-04-14 21:18:52
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: List of articles with current category
Ah OK, so you want to display the lists on an individual article page as well? Not just on a category page?
In the previous code example, we checked against the requested category (the category that is in the URL). When on an individual article page, which category should the article lists have? Should list one have the same category 1 as the individual article’s category 1, and ditto for list two and category 2?
Offline
#15 2010-04-15 06:18:22
- bmwg
- Member
- Registered: 2010-04-06
- Posts: 39
Re: List of articles with current category
This part of my page is basically three divs. 2 for the lists of products and info material and one for the actual content. I use your code for the two lists. And I have the following code on my content div:
<txp:if_individual_article>
<txp:article form="myForm" limit="1"/>
<txp:else />
<txp:article status="sticky" limit="1"/>
</txp:if_individual_article>
Since I use hierarchical categories for my product groups, the code displays the sticky article for the selected category (product group) with some general information about the group when no individual article is selected. And the product article once it is selected in the list. So far everything works fine.
However I don’t want the lists to change if the user doesn’t change the category. And I don’t understand this behaviour because your code fills the lists according to the current category. I don’t see how the category changes. After clicking on a list item I get url/section/category/article. (Before: url/section/category). Shouldn’t it still be the same category? That is shouldn’t the lists still load the same items even if I’m on an individual article page?
Offline
#16 2010-04-15 22:34:55
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: List of articles with current category
<txp:article />
is context sensitive, so on an individual article page it will only ever display that individual article. If you still want the article lists on individual article pages, you’ll need to use <txp:article_custom />
, and place the code outside the if_category tags. Instead of <txp:article />
you can use <txp:article_custom section='<txp:section />' category='<txp:category />' />
. But then you’ll have another problem:
And I don’t understand this behaviour because your code fills the lists according to the current category. I don’t see how the category changes. After clicking on a list item I get url/section/category/article. (Before: url/section/category).
So you are using gbp_permanent_links. I don’t know if you’ve noticed that the ‘category’ in the URL /section/category/article is always either the article’s category1 or category2 (you can set that in the permanent link rule settings). Let’s say it’s set to category1. If a visitor clicked a link on a category page in the second list, an individual article is displayed that has the requested category as its category2, but category1 will be in the URL. And the latter determines the value of <txp:category />
.
Offline
#17 2010-04-16 07:04:00
- bmwg
- Member
- Registered: 2010-04-06
- Posts: 39
Re: List of articles with current category
Thanks.
I think I’ll use keywords to seperate the items. Seems easier.
Offline