Auto-hide menu item when no content items to display

Discuss the development and implementation of Joomla! 1.0.x templates here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
cooperate
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Sun Aug 20, 2006 8:56 pm
Location: Muenster, Germany
Contact:

Auto-hide menu item when no content items to display

Post by cooperate » Fri Aug 31, 2007 10:04 pm

Hi everyone,

I want to enlarge an existing website with a new "News" menu (Blog - Content Category). However, there will be times when there are no content items to display, because none are currently published. Instead of getting a "There are no Items to display" message, I want the menu item itself to disappear. When a content item is published, I want the menu item to re-appear. I'll happily split the navigation into two separate modules: one "news" module that can be unloaded, and another menu module including all the other menu items that is always visible.

Unfortunaely, I do know nothing about PHP. But I assume that it must be possible to
a) determine the number of currently active content items within a given content category and
b) hide (i.e. "not load") the news module when the number of acive items is zero.
The idea came to me when I saw this in the Solarflare II template:

Code: Select all

if ( mosCountModules( 'top' ) ) { mosLoadModules ( 'top', -2 ); }
Could someone help me with the bit of code that is required to acomplish this?

Thank you from
cooperate!
Greetings from cooperate

fadine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Wed Aug 23, 2006 4:37 am
Contact:

Re: Auto-hide menu item when no content items to display

Post by fadine » Sat Sep 01, 2007 10:02 am

You need a new menu module.
http://pachay.com
Free templates and component for Joomla.

cooperate
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Sun Aug 20, 2006 8:56 pm
Location: Muenster, Germany
Contact:

Re: Auto-hide menu item when no content items to display

Post by cooperate » Sat Sep 01, 2007 1:55 pm

fadine wrote: You need a new menu module.
I am happy with that.
What I need is help with a piece of code for the template, that
1) queries the database for published items in the category "news" (or its respective category id),
2) returns the number of currently active items, and
3) loads the module *only* if the item number is >0.

I've searched the developer pages already, but I just don't know enough about PHP and MySQL queries to have any hope of actually doing it myself... Any help?
Greetings from cooperate


Locked

Return to “Templates & CSS - 1.0.x”