Keyword

Display a message if no news or posts

  • Richard Pigden
  • Richard Pigden's Avatar Topic Author
  • Offline
  • New Member
More
14 years 1 week ago #90463 by Richard Pigden
Display a message if no news or posts was created by Richard Pigden
Hi everyone
This may be a long shot but I wonder if there are any good programmers out there who could point me in the right direction for getting a message to appear if my K2 category has no current news items to display?

I'm making use of the autoarchiver plugin so once a story has expired it automatically moves to a different category, which means when its a slow month my main News page can be empty.

What I'd like to have is when it is empty a message should appear with something like "We currently have no news, but check back soon, bla bla bla..." and of course as soon as a new item is posted, the message should vanish again.

I'm looking around the category.php file around line 167 (I'm only using primary items), but can't quite get it to echo a message based on some kind of else or if statement - my PHP is very poor!

I've scoured the forum but cannot seem to find a way to do this so appreciate any ideas for this.

Thanks

Rich

*Edit*

Problem solved, its amazing how easy it is when you stop and think about it!

In case anyone else should ever need it, here's what I did to add a message to my category page if there was no new events/posts...

At the end of the category.php page, just after the final </div> add this:

<div id="k2nonews">
        <?php
if(count($this->leading)==0)
echo 'We currently have no news, please check back soon...';
?>
</div>

I only use leading posts, but if you have primary and others set you may well need to play around with this more.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum