Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-02 19:47:34

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

[howto] Display articles grouped by categories (aka rss_suparchive_bycat)

If you want to display all articles grouped by categories, the way rss_suparchive_bycat does but this time with native core TXP commands and more control over what happen this is possible.

First, in your template you need to do the call and the sorting :

<txp:article_custom form="TheGoodForm" limit="9999" section="article" sortby="Category1,Title" sortdir="asc" />

Using article_custom and section attribute is optionnal, if you don’t need to you can not do it.

So that does work with any classical article form, but it doesn’t display the category. Your visitors will have some trouble with this. So we use a little of Zem mojo and mary’s explanations, and create a form (here TheGoodForm) and in it:

<txp:if_different>
<h2><txp:category1 title=1 /></h2>
</txp:if_different>
<h3><txp:permlink><txp:title /></txp:permlink> 
<txp:excerpt />

And bingo. As usual, all of this may be tweaked to one’s own needs.

Why bother since rss_suparchive_bycat does it ? Well mostly because it allow you to use form, and so more complex and precise control. For example you can display a little red flag next to your spoiler articles, if they have a Spoiler custom field with a warning in it; things like that.

It only work with TXP 4.0.2 and up.

Last edited by Jeremie (2005-11-02 19:49:04)

Offline

#2 2005-11-02 20:32:34

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

Jeremie,
Thanks, I am going to try to use this with Mary’s upm_category_image and Alex’s zem_article_image like this:

<code>
<txp:if_different>
<txp:upm_category1_image />
</txp:if_different>
<h3><txp:permlink><txp:title /></txp:permlink></h3>
<txp:zem_article_thumb />
</code>

It will be nice when more of these great plugins get hardcoded into the txp install, and maybe some of them will never be, but for now, if you need those things, this works nicely.

thanks for your help.
This is a great little Forum Section.

Matthew


Offline

#3 2005-11-04 00:46:05

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

That didn’t work. I guess Mary’s plugin isn’t designed to work in that manner. (for the moment :)

Matthew

Last edited by ma_smith (2005-11-04 00:48:05)


Offline

#4 2005-11-04 01:16:48

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

I don’t know exactly how txp:if_different work, but I doubt it can guess the content or output of plugins yes. Maybe you should try with the core article_image function, to check is that is a plugin thing.

Offline

#5 2005-11-04 01:57:14

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

Jeremie,

I didn’t quite understand what you meant by the “core” article_image? I assume you mean something like this:
<code>
<txp:if_different>
<txp:article_image />
</txp:if_different>
<div class=“thumb”>
<ul>
<li><a href=”<txp:permlink />” title=”<txp:title />” ><txp:zem_article_thumb /></a></li>
</ul>
</div><!—close thumb—>
</code>

If that is what you mean, that outputs the large image, followed by the thumbnail and does so in order of categories, given the article_custom you have above. Unfortunately, it doesn’t call the plugin, or the plugin isn’t compatible with this tag. I feel like asking mary for help, but at the moment she is undertaking some other work. Someday, it would be a great feature.

Again, thanks this is a great way to make this work.

for reference on how I am currently using it see artiswork

Matthew


Offline

#6 2006-01-16 04:30:36

Dawk
Member
Registered: 2005-02-22
Posts: 74

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

Does someone know on how I would… display article Excerpts by Category?

ie.
Title Link
Excerpt

Title Link
Excerpt

I’m also really curious about…
Title Link
Excerpt
+ read more link

Thanks a bunch :)

Offline

#7 2006-01-16 04:52:29

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

That’s exactly what’s is done here. Re-read my first post on this thread.

If you want a “Read more” (on top of the title being a link) you can add the the form this last line:

<p><txp:permlink>Read more.</txp:permlink></p>

Offline

#8 2006-01-16 05:41:54

Dawk
Member
Registered: 2005-02-22
Posts: 74

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

Thanks a bunch Jeremie,

I found another thread that walked me thru creating a new article form & got my main news working w/excerpts/read more.
A couple things just clicked & makes sense now ;) txp noob here!

Thanks again, works like a charm!

Offline

#9 2006-01-16 05:46:07

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

No problem, all of us were a Textpattern newbie at some point :)

Offline

#10 2006-01-17 12:54:49

tormu
Member
From: Finland
Registered: 2005-12-29
Posts: 17
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

Yeah, doing the list this way takes about half of CPU usage compared to making it with superarchive_bycat, but if I wanna limit the articles listed below the category title and would like to show all them only if the visitor clicks the category title (link), is it possible to output the amount of articles belonging to the category, like it is possible in superachive_bycat?

like

Category (amount of articles, for example 15)<br />
- article 1<br />
- article 2<br />

Category2 (19)<br />
- article 1<br />
- article 2

EDIT:

Actually I don’t know how to limit the amount of articles showing under the category either :((
Please.. any way to do those two things by this method?

Last edited by tormu (2006-01-20 09:52:09)

Offline

#11 2006-01-28 01:02:10

mattmikulla
Member
From: Nashville Tennessee
Registered: 2004-08-25
Posts: 281
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

Not sure if this is relevent to what you are asking tormu, but I only want to display articles that are in the current category. No other links period.

For example, I have a photo gallery. If I am currently viewing a photo in the section “photography” and the category1 “landscape”, I want to have only thumbnails in the category landscape displayed.

Currently using the form called article_thumbs:

<li>
<a href="<txp:permlink />" title="<txp:title />"><txp:bau_article_thumb /></a>
</li>

And to display the thumnails in the sidebar:

<txp:if_individual_article>
<div id="thumb_container">
<txp:rss_suparchive_bycat section="photography" useartcat1="1" showcats="0" showcatcount="0" formwraptag="ul" form="article_thumbs" />
</div>
<txp:else />
some other content
</txp:if_individual_article>

It works like a charm. When I view a photo from the category landscape, only the thumbnails of articles in the category lanscape show. Not a list of all thumbnails seperated by category.

I would love to do this with core tags.


Art Rogue – Fine Art Photography

Offline

#12 2006-01-29 17:56:15

kevinpotts
Member
From: Kansas City
Registered: 2004-12-07
Posts: 366
Website

Re: [howto] Display articles grouped by categories (aka rss_suparchive_bycat)

Just letting you know this code example came in very useful when developing a sitemap for a client. I used a bit of javascript to make the whole thing more manageable as well:

http://travelwithyourkids.mrbood.com/sitemap

Offline

Board footer

Powered by FluxBB