Main
Index
Search
Posts
Who's
Online
Log
In

Home: Discontinued/Classic Products: Article Manager 2:
Hiding Empty Categories

 

 


Donna
Staff / Moderator


Aug 7, 2009, 3:37 PM

Post #1 of 1 (1615 views)
Shortcut
Hiding Empty Categories Can't Post

So you wanna hide or otherwise do something differently with empty categories? Are you using PHP, or some other dynamic code (other than SSI's)? Well, c'mon down!

We'll basically be following Ross's tutorial on how to get the number of articles appear in each category.

There are a couple of minor differences -- first, you'll want to edit the numberOfArticles.html template he attached a wee bit -- use the one I've attached to this tutorial instead. (It just makes sure there aren't any superflous spaces or linebreaks, and removes the parenthesis Ross had.)

The publish rule stays exactly the same.

The changes to the categoryMenu.html template will be a bit different. Instead of the include Ross mentions, you can use code like this (note: This is the PHP version. If you're using another programming language, you'll have to write your own version. Note that this will NOT work with a templateIf & SSI's, but could be converted to ASP, ColdFusion, etc. Your site must be already using PHP, or converted to use PHP, for this to work.)


Code
<!-- templatecell : categoryRow --> 
<?php if (file_get_contents("$published.numberOfArticles.filepath$")): ?>
<a href="$published.categoryIndex.url$">$category.name$</a><br>
<?php endif ?>

<!-- /templatecell : categoryRow -->


What this one does is says "If there are any articles in the category, show this code." Or more specifically, "If the value is anything other than 0, show this code." The file it's reading displays the number of articles in a category. So if there are NO articles in a category... nothing shows.

You can, of course, modify this as much as you want, especially if you know a little PHP. :)

Play around with it, see how you want things to display, and have fun -- but make sure you save a backup first!

Donna

--
support@interactivetools.com