Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-01-09 08:50:53
- Faolan
- New Member
- Registered: 2009-01-09
- Posts: 3
Displaying articles from all sections by category.
Hi all,
I’m currently putting together a website for an arts collective, and I’ve run into a stumbling block.
I’d like to have a navigation menu with a list of categories (say “music”, “visual art”, “gigs”, “writing”, etc.), so that all articles published across the site that relate to music, visual art or whatever can be accessed in one place.
This strikes me as something that shouldn’t be hard to achieve, but for some reason, the only articles that are indexed by the category system are those that appear on the front page. I feel like I’m missing some small setting that will completely solve this problem, but I just can’t figure it out.
If anyone has any feedback, it would be much appreciated.
-F
Offline
Re: Displaying articles from all sections by category.
Does this help?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Displaying articles from all sections by category.
Hello,
I’m having the same issue. I have a blog section, which I don’t want to appear on front page. here is my site example:
http://thedept.com/index.php?s=blog
If you select a category tag like “Sci-Fi” or “Cinema”, you are taken to that category page, but it’s blank.
I’ve looked at “TheGoodForm” solution that was mentioned, but I’m not sure where to place the <txp:article_custom form=“TheGoodForm”>
I’ve made a few attempts to place it within my Blog page, but It doesn’t seem to work.
Any suggestions or tips?
Thanks!
Best,
-Elstrausso
Offline
#4 2009-01-09 18:38:40
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Displaying articles from all sections by category.
elstrausso wrote:
but I’m not sure where to place the
<txp:article_custom form="TheGoodForm">
On the front page, but you need to wrap it in if_category tags:
<txp:if_category>
<txp:article_custom form="TheGoodForm" />
<txp:else />
// here your tags for the regular front page
</txp:if_category>
Offline
#5 2009-01-10 06:16:22
- Faolan
- New Member
- Registered: 2009-01-09
- Posts: 3
Re: Displaying articles from all sections by category.
Thanks for the replies; I think that method will be helpful, I’ve just got to play around with it a bit and see if I can do what I need with it.
It strikes me though that I must be missing something about the section > category workflow TXP uses. I can’t entirely understand why categorised articles should only be listed if they’re posted to sections which appear on the front page. It would make sense that categories should be retrieved independently of the section they’re posted to, and then have an option to target a specific section if needed.
Can anyone shed more light on why things occur the way they do?
Thanks.
-Faolan
Oh. One thing I should add would be that it’d be nice if clicking on the category under the article would bring one to a list of articles in the same category.
As far as I can see, this method doesn’t allow for that.
Last edited by Faolan (2009-01-10 06:53:43)
Offline
#6 2009-01-10 07:29:51
- Faolan
- New Member
- Registered: 2009-01-09
- Posts: 3
Re: Displaying articles from all sections by category.
Never mind, I was wrong.
I’ve made it work in the way I wanted it by substituting <txp:category1 for< txp:category, and tweaking the output a bit.
It works really well.
Thanks all.
When I’m done, I’ll post the results as a proof of concept.
Last edited by Faolan (2009-01-10 07:46:44)
Offline
Re: Displaying articles from all sections by category.
Hello,
I’m still having issues trying to implement the code you suggested. Not sure what I’m doing wrong, but it seems that when I select a category, its collecting everything from the blog section, rather than just the specific tag results. ex. http://thedept.com/index.php?c=News
Thanks
Elstrausso
This is my code for main page:
<!— center —>
<div id= “content”>
<div class= “blogcontent”>
<txp:if_category>
<h2><txp:category title=“1” /></h2>
<txp:article_custom form=“TheGoodForm” />
<txp:else />
<txp:article form=“project” limit=“15” pageby=“0” pgonly=“0” sort=“Posted desc” status=“4” allowoverride=“1” />
<txp:article_image/>
<txp:else />
<txp:if_search>
<h2><txp:text item=“search_results” />: <txp:page_url type=“q” /></h2>
</txp:if_search>
<div class=“hfeed”>
<txp:article limit=“15” />
</txp:if_category>
</div>
</div>
Offline
Re: Displaying articles from all sections by category.
Your if_search conditional should either be placed after the first <txp:else />
or outside the if_category conditional. You have a second <txp:else />
which does not work.
Apart from that, its not clear why your article results are not as you would want without seeing the contents of your form.
Offline
Re: Displaying articles from all sections by category.
The code in Jeremie’s post linked to by colak above, is for creating a list of articles grouped by category, for instance for a list of links to articles in an archive. “article_custom” is not context-sensitive so it shows all the articles you tell it to regardless of whether you are showing a section page, a category page or individual article. You can limit what it shows by using the section
and category
attributes.
It sounds to me like you want to show only the sci-fi articles when you are on a category page. To do that forget Jeremie’s example and use the standard txp:article (without custom) tag and your own form and listform. txp_article is context-sensitive so it will show only those articles that apply for that section, e.g.
?s=news
– txp:article shows only articles in the “news” section
?s=news?&c=Sci-Fi
– txp:article shows only articles in the “news” section that have been given the category “Sci-Fi”.
Check your code carefully too. It looks like you have two txp:else tags in there. Maybe you want:
<!-- center -->
<div id= "content">
<div class= "blogcontent">
<txp:if_search>
<h2><txp:text item="search_results" />: <txp:page_url type="q" /></h2>
<txp:article limit="15" />
<txp:else />
<txp:if_article_list>
<txp:if_category>
<h2><txp:section title="1" /> – <txp:category title="1" /></h2>
<txp:else />
<h2><txp:section title="1" /></h2>
</txp:if_category>
</txp:if_article_list>
<txp:article form="project" listform="my-list-form" limit="15" pageby="0" pgonly="0" sort="Posted desc" status="4" allowoverride="1" />
</txp:if_search>
maybe something like that? (I’d put the txp:article_image into your form / listform).
TXP Builders – finely-crafted code, design and txp
Offline
Re: Displaying articles from all sections by category.
thanks for the responses, I’ll give your suggestion a try.
best,
elstrausso
Offline