Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-28 20:10:49

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

[howto] Make a category listing use the same section and template

I’ve had to try and help one or two here to sort out their category listings. These are the lists generated when you click on the linked category of an article. By default these listings use the front-page or default section and whichever template is attached. If you have a front-page which is more of a splash-page or simple entry point to your main site this can be a total pain in the arse trying to make it do two different things and keep them separate from each other. So here is a way of making your category links stay in the same section and use the same template as the original articles.

In your default form or any form you use to display articles with category links, instead of using the standard <txp:category1 link="1" /> tag, replace it with <a href="<txp:site_url /><txp:section />/?c=<txp:category1 />"><txp:category1 title=1 /></a>. For category2 simply change the numbers in the category tags. If you want to use a different form template for a category listing then use the <txp:if_category><txp:else /></txp:if_category> tags to separate your code.

Last edited by thebombsite (2007-01-27 23:12:37)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#2 2005-10-31 10:40:33

mearso
Member
From: Wales
Registered: 2004-03-25
Posts: 18
Website

Re: [howto] Make a category listing use the same section and template

I use the nifty plug-in glz_crumbs

Which give plenty of breadcrumb options

<code><txp:glz_crumbs site /></code> in an article form does the trick

Offline

#3 2005-10-31 10:42:44

mearso
Member
From: Wales
Registered: 2004-03-25
Posts: 18
Website

Re: [howto] Make a category listing use the same section and template

Sorry everyone. I just read the guidelines after posting!
No more forum pollution from me!

Offline

#4 2005-10-31 14:08:11

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [howto] Make a category listing use the same section and template

Well this piece of code is for a specific purpose – replacing the standard category1 and category2 links in an article form – and doesn’t require a plug-in. If someone wants “breadcrumbs” that’s a different kettle of fish but thanks for the tip anyway. :)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#5 2005-11-01 01:22:43

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

Re: [howto] Make a category listing use the same section and template

Stuart,
I tried using this with Mary’s upm_category_image plugin, like this:
<code>
<a href=”<txp:site_url /><txp:section />/?c=<txp:category1 />”><txp:upm_category1_image />
</a>
</code>

It doesn’t even show up. Hmm. Guess that’s not allowed? Any thoughts?

I would love to have a category_image list that was attached to the archives page for instance.

Thanks,

matthew


Offline

#6 2005-11-01 22:05:46

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [howto] Make a category listing use the same section and template

Have you updated TXP? I can’t remember when the <txp:site_url /> tag came in. TXP 4.0.2 is now available and you should be using it. :) Also the <txp:section /> tag picks up the section you are currently viewing. That’s the point. The resulting category list uses the same section and thus template that the link is situated in rather than going to the front-page (default template).

Last edited by thebombsite (2007-01-27 23:11:33)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#7 2005-11-02 03:50:09

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

Re: [howto] Make a category listing use the same section and template

Gotcha, stuart. That makes sense. I hope to update soon, though there is much on the plate at the moment. artiswork is coming right along. Thanks for your thoughts there.

Matthew


Offline

#8 2005-11-28 08:57:26

andrea
Member
From: la la land
Registered: 2004-02-24
Posts: 62
Website

Re: [howto] Make a category listing use the same section and template

thank you so much for this! i was going nuts trying to figure out what to do here, hours and hours now. phew. thanks.

update: another way, using a plugin though, is <a href=“http://forum.textpattern.com/viewtopic.php?id=3235”>dak_categories</a>, with the most recent version <a href=“http://rise.lewander.com/textpattern/101/dak-categories-04-edit”>here</a>..

Last edited by andrea (2005-11-28 09:26:05)

Offline

#9 2005-11-28 10:48:22

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [howto] Make a category listing use the same section and template

Thanks andrea but my current mission in life is to ease the load on everyone’s’ hard-done-by databases and give them a rest by reducing drug depe…. sorry plug-in dependency. You might want to read-up on all the other plug-ins you can replace these days. And I’m not even going to mention rss_suparchive. Oooops. ;)

Last edited by thebombsite (2007-01-27 23:13:54)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#10 2006-02-04 11:03:00

sauo
Member
Registered: 2005-07-05
Posts: 11

Re: [howto] Make a category listing use the same section and template

> thebombsite wrote:
>In your default form or any form you use to display articles with category links, instead of using the standard <code><txp:category1 link=“1” /></code> tag, replace it with <code><a href=”<txp:site_url /><txp:section />/?c=<txp:category1 />”><txp:category1 /></a></code>.

Thank you Thebombsite!!! It works very well :) However I have some more unfortunately…. How can I do the same thing (linking to mysite.com/blog/?c=Category) from the <txp:popup> dropdown browse menu? Thanx!

Offline

#11 2006-02-04 13:31:07

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [howto] Make a category listing use the same section and template

I can’t help you with that myself I’m afraid as the drop-down is hard-coded. You could replace it with a listing using the method I describe here which includes this little trick. You would only need the code between the “if_different” tags (including the tags) for the form template as you would only want the categories listed without article titles. And for the “article_custom” tag in your page or sidebar template you don’t need the “section” attribute if you want categories from all sections to be listed.

Last edited by thebombsite (2007-01-27 23:15:20)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#12 2006-02-06 10:28:59

shafina
Member
From: pj, malaysia
Registered: 2006-01-04
Posts: 17
Website

Re: [howto] Make a category listing use the same section and template

thanks a lot for this tip! the category ‘section’ was giving me a headache and i thought i’d just leave it, but you’ve helped me sort it out finally.

i have a sample page here

Offline

Board footer

Powered by FluxBB