Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-19 06:10:05

scdoody
Member
Registered: 2006-10-18
Posts: 129

Exclude certain articles based on category form article listing.

On the homepage of my blog I want to display the articles from all categories except for one. Right now, to display ALL categories I use this:

<txp:article limit="6" />

<txp:if_individual_article>
		<p><txp:link_to_prev><txp:prev_title /></txp:link_to_prev> 
			<txp:link_to_next><txp:next_title /></txp:link_to_next></p>
<txp:else />
		<p><txp:older><txp:text item="older" /></txp:older> 
			<txp:newer><txp:text item="newer" /></txp:newer></p>
</txp:if_individual_article>

What do I do to exclude a category called ‘ideas’?? I have looked around on the FAQ and haven’t found anything. I know there is an attribute exclude=“ideas” however it seems like this can only be used in a category list rather than an article list.

Any help is greatly appreciated!!!

Thanks!!!

Offline

#2 2006-10-19 06:19:42

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Exclude certain articles based on category form article listing.

<txp:if_article_category name="ideas"> 
No Show content? 
<txp:else />
Your current article form content
</txp:if_article_category>

if_article_category Textbook

name is the correct attribute ;)

Last edited by rsilletti (2006-10-19 06:38:36)

Offline

#3 2006-10-19 06:22:20

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: Exclude certain articles based on category form article listing.

Edit: Damn it! Too slow.

Hi scdoody,

Try this (I’m not 100% certain it will work). In your Article Form, drop in the <txp:if_article_category> conditional.

<txp:if_article_category name="ideas">
<txp:else />
<txp:title />
<txp:body />

...


</txp:if_article_category>

Last edited by mstwntd (2006-10-19 06:24:06)

Offline

#4 2006-10-22 05:13:31

scdoody
Member
Registered: 2006-10-18
Posts: 129

Re: Exclude certain articles based on category form article listing.

These suggestions didn’t seem to work. Can anyone else provide any insight on how to exclude a certain category of articles from an article listing?

Thanks!

Offline

#5 2006-10-22 10:59:36

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Exclude certain articles based on category form article listing.

It should work. You should point to this article form in your article tag though. So, if the article form with the above mentioned code is called ‘no-ideas’, use <txp:article listform="no-ideas" limit="6" /> on your page.

Offline

#6 2006-10-23 13:43:48

douglgm
Member
From: Bristol
Registered: 2006-08-23
Posts: 182
Website

Re: Exclude certain articles based on category form article listing.

I understand how the form is being used to filter out the undesirable articles, but this doesn’t stop them from appearing when following the next and previous buttons. Is there any way to do this?

Offline

#7 2006-10-27 19:41:19

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Exclude certain articles based on category form article listing.

‘Next’ and ‘previous’ are used on individual article pages, not in article lists. Individual articles use their own section page, so the examples given above do not apply to this situation.

Offline

#8 2013-07-06 05:25:09

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Exclude certain articles based on category form article listing.

rsilletti a écrit:

<txp:if_article_category name=“ideas”>
No Show content?
<txp:else />
Your current article form content
</txp:if_article_category>

It doesn’t work for me because of the limit attribute. As the condition is inside the form, the content of the article is not displayed, but the article is already called…
For exemple if the article limit on my page is 3 and there are 2 articles which souldn’t be displayed, the page will show only one article content.
I’m working on it…
Any ideas?
Thx!

Last edited by NicolasGraph (2013-07-06 05:27:16)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#9 2013-07-06 09:39:49

etc
Developer
Registered: 2010-11-11
Posts: 5,394
Website GitHub

Re: Exclude certain articles based on category form article listing.

Not sure you can do it with <txp:article />. If you don’t need the prev/next tags, there is an article_custom solution:

<txp:article_custom category='<txp:category_list exclude="ideas" break="," ... />' ... />

Offline

#10 2013-07-07 07:22:34

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Exclude certain articles based on category form article listing.

Thanks but, ideally, i’d like to keep the prev/next.
Anyway I’m not sure that it could works for me because I want to exclude the Feature category, but the articles in this category are also in an other one which will be display…

Last edited by NicolasGraph (2013-07-07 07:22:53)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#11 2013-07-07 22:31:41

etc
Developer
Registered: 2010-11-11
Posts: 5,394
Website GitHub

Re: Exclude certain articles based on category form article listing.

The simplest solution will then be to assign “ideas” articles to some section that has On front page option set to No. This will exclude them from all article listings except for that very section. Of course, that may be too restrictive, and in this case you’ll need to talk directly to the DB.

<txp:etc_query name="filter" data="SELECT ID FROM textpattern WHERE Category1 != 'ideas' AND Category2 != 'ideas' AND Status = 4 ORDER BY Posted DESC" break="," />

will retrieve a list of IDs of the required articles and store it in <txp:variable name="filter" />. You should actually add other filtering options to WHERE cause, to exclude future and expired articles, but those are rare.

Now, on the individual page, the prev and next links can be obtained with

<txp:etc_query data="[{?filter}]" query="row[text()='{?thisid}']">
<txp:permlink id="{preceding-sibling::row[1]?}">Previous</txp:permlink>
<txp:permlink id="{following-sibling::row[1]?}">Next</txp:permlink>
</txp:etc_query>

On article listing pages, you’ll need to paginate the articles, like this:

<!-- articles display -->
<txp:article_custom id='<txp:etc_query data="[{?filter}]" specials="data,offset" globals="variable,_GET" limit="6" offset="{?page|0|intval.-1.*6}" break="," />' form="your_form" />

and the pagination bar can be constructed in the spirit of this article. But it’s amazing that such a simple question requires so much work.

Offline

#12 2013-07-08 05:19:42

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Exclude certain articles based on category form article listing.

etc a écrit:

But it’s amazing that such a simple question requires so much work.

Yes, so much work… from you… Thx!


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

Board footer

Powered by FluxBB