Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-07-12 20:41:33

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

outputing ONLY articles belonging to a particular category

Hi Please forgive my ignorance, im a txp noob.

*I would like to out ONLY certain articles belonging to a particular category e.g “MyNews”. *

I then want to place this in a custom form:-
<txp:article_custom limit=3 form=“MyNews_Articles” />

I looked for over an hour and haven’t found any answers, im sure this must have been asked before but I can’t find any references can someone point me inthe right direction please.

Many thx

Timid


I think, therefore I AM, … … er … I think :-?

Offline

#2 2007-07-12 22:27:21

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: outputing ONLY articles belonging to a particular category

If I understood corretly, it would be simple, just add a category="category name" to inside the <txp:article_custom />-tag. Like this, in your case:

<txp:article_custom limit="3" form="MyNews_Articles" category="MyNews" />

Last edited by Gocom (2007-07-12 22:28:59)

Offline

#3 2007-07-13 06:05:39

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: outputing ONLY articles belonging to a particular category

Thx that worked a treat and easy too!

One more question…. On the main page I DON’T want to show This specific category.
How would i exclude it from the output of that part of the site, as I only ant to show “MyNews” in a my news article_custom section.


I think, therefore I AM, … … er … I think :-?

Offline

#4 2007-07-13 07:44:07

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: outputing ONLY articles belonging to a particular category

If I again understood correctly, you want to show articles only in *news*-section? So, then you have to add there <txp:if_section name="section name" />-tags, like this:

<txp:if_section name="news">
<txp:article_custom limit="3" form="MyNews_Articles" category="MyNews" />
</txp:if_section>

Last edited by Gocom (2007-07-13 07:45:47)

Offline

#5 2007-07-13 08:24:30

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: outputing ONLY articles belonging to a particular category

I apologise for my lack of clarity, i’ll try to elaborate

The default page has two area’s where articles are output;
1. the standard way where all article of every category are shown.
2. and <txp:article_custom limit=“3” form=“MyNews_Articles” category=“MyNews” /> ONLY news articles.

However i would like to exclude [category=“MyNews”] from de default standard output area. (i’m not using sections yet.)

How could i do this


I think, therefore I AM, … … er … I think :-?

Offline

#6 2007-07-13 08:54:24

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: outputing ONLY articles belonging to a particular category

So you don’t want to show that <txp:article_custom /> on frontpage, but in anywhere else? Or you just want to show it when you are browsing category="MyNews"? Or you want to show it when reading an single article? Sorry, I’m little confused, somehow I just don’t understand what you’re saing. But a matter what, here’s answers:

If you want to show it elsewhere than frontpage ( you need to download and innstall plugin named glx_if ):

<txp:glx_if_not_frontpage>
<txp:article_custom limit="3" form="MyNews_Articles" category="MyNews" />
</txp:glx_if_not_frontpage>

If you want to show it when browsing current category:

<txp:if_category name="MyNews">
<txp:article_custom limit="3" form="MyNews_Articles" category="MyNews" />
</txp:if_category>

Or if you want to show it when you’re only reading single article:

<txp:if_individual_article>
<txp:article_custom limit="3" form="MyNews_Articles" category="MyNews" />
</txp:if_individual_article>

Or you can use in those <txp:else />-tag, that you can output the default article outputting style, and those two won’t come up in same time. I hope there is something that helps you, if not, just explain more, and I (or someone else) will get back in to your problem :-)

And url, or example-code of your case would be nice :-)

Last edited by Gocom (2007-07-13 08:56:59)

Offline

#7 2007-07-13 09:19:59

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: outputing ONLY articles belonging to a particular category

Some great tips, but unfortunately not what i meant,

I’ve included a link to a screendump of what i am trying to achieve:-
http://idisk.pixeloid.co.uk/txp-categories.jpg

This is all happening on the default page. I am not using sections

The site is at:-
http://meanttoshine.org/weblog

Thx again for your time

Last edited by Timid&friendly (2007-07-13 09:23:13)


I think, therefore I AM, … … er … I think :-?

Offline

#8 2007-07-13 10:38:38

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: outputing ONLY articles belonging to a particular category

Oh, it was that simple problem, my bad. Or it’s simple if you need only some particular categories. You just use absolutely same code that before, but list categories comma seperated, like this:

<txp:if_individual_article>
<txp:article />
<txp:else />
<txp:article_custom limit="5" form="default" category="other,casual,food" />
</txp:if_individual_article>

And replace with it the default <txp:article />-tag. Have fun with it :-)

Last edited by Gocom (2007-07-13 10:42:14)

Offline

#9 2007-07-13 12:15:25

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: outputing ONLY articles belonging to a particular category

that seems to do the trick, THX.

So there is No “!NOT” function in txp

as in if (!category name=“MyNews”) { statement; }

Last edited by Timid&friendly (2007-07-13 12:16:53)


I think, therefore I AM, … … er … I think :-?

Offline

#10 2007-07-13 12:42:51

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: outputing ONLY articles belonging to a particular category

No, there isn’t, if you don’t use raw php to get the names of categories. :-)

Last edited by Gocom (2007-07-13 12:43:31)

Offline

#11 2007-07-13 13:47:01

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: outputing ONLY articles belonging to a particular category

Timid&friendly wrote:

that seems to do the trick, THX.
So there is No “!NOT” function in txp
as in if (!category name=“MyNews”) { statement; }

…or you could have easily used sections

Offline

#12 2007-07-13 14:43:19

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: outputing ONLY articles belonging to a particular category

I agree whit iblastoff, it would be greatly easier :-) And after all you can still put all sections to a same page, same kinda like you did with categories.

Offline

Board footer

Powered by FluxBB