Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-05-31 19:52:59

anand
Member
From: netherlands
Registered: 2005-07-13
Posts: 16
Website

how do i display custom message if ther is no article in a category

i have categories , i want to display a message if there are no article on that page for instance “sorry there is no content availeble at the moment “ right now i get an empty page .

how can i do this thx….

Offline

#2 2006-06-01 05:21:25

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: how do i display custom message if ther is no article in a category

Put this snippet into your page template anywhere below txp:article:

<txp:php>
global $thispage;
if ($thispage['total']==0 ) echo ("No articles found.");
</txp:php>

I use this method to display a message when full text search returns no hits.

Offline

#3 2006-06-01 07:40:13

anand
Member
From: netherlands
Registered: 2005-07-13
Posts: 16
Website

Re: how do i display custom message if ther is no article in a category

it doesn’t seem to work if your category is a page , it does display the message , but there are article in the catergory
i use the wow menu plug in to display the category as a menu check the link out http://samaanta.project-8.nl/index.php?s=chauwtaal
under the calender you see the sub-menu generated with wow plugin.

here is my code and setup

each catergory has it’s own html page and this is the code for the article
<code><txp:article_custom form=“activiteit” category=“chauwtaal” sortby=“Posted” sortdir=“desc” listform=“sectie_artikel” />
</code>

now i put the code for displaying the message under the code that’s above
<code>
<txp:php>
global $thispage;
if ($thispage[‘total’]==0 ) echo (“<p>Er zijn momenteel geen activiteiten in deze category.</p>”);
</txp:php>
</code>

any idea why???? or anybody other suguestions?

Offline

#4 2006-06-01 08:55:58

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,125
Website GitHub Mastodon Twitter

Re: how do i display custom message if ther is no article in a category

My main suggestion would be not to have categories without any articles attached to them. Why have visitors click for nothing. I understand that the categories you have created will eventually have content but why not create them as you need them?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2006-06-01 11:37:58

anand
Member
From: netherlands
Registered: 2005-07-13
Posts: 16
Website

Re: how do i display custom message if ther is no article in a category

well main goal is actually is to create the catergory dynamicly, meaning i only have to make an article to the catergorie and then it’s there, so i don’t have to make a category for the article .
but textpattern can’t do this as far as i know , so my sugguestion is to have the category there but display a message if it’s empty
if this is not possible then , i would have to scratch the whole idea ,
but if anybody have a suguestion , please let me know …. :)

Offline

#6 2006-06-01 13:13:46

anand
Member
From: netherlands
Registered: 2005-07-13
Posts: 16
Website

Re: how do i display custom message if ther is no article in a category

and idea is to let them go on the error page , how do i do that
so if category is empty , redirect to error page or some other page

Offline

#7 2006-06-01 13:57:59

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

Re: how do i display custom message if ther is no article in a category

I think you can use the chh_if_data plugin for this.

Offline

Board footer

Powered by FluxBB