CGProducts and Menus - Producing menu if category has items
Posted: Thu May 28, 2015 8:37 am
I'm doing some tweaking work on an old website I built (changing it for a fully responsive template and updating things is a muuuuuch longer project!) and one of the things I have noticed is that the nature of my menu structure means I am producing a heading for each category, and it then calls the Products module to produce the links below.
As the people that work at the company change and replace pages, we've ended up with a few empty categories which I don't notice.
So, I thought it would be better to first check if the category has items, then produce the heading and link list.
The code I've started with so far, is:
However, that doesn't seem to work - this is an empty category I'm testing it on.
What do I need to do to make it effectively check if that category has items, and only produce the following code if it does?
Cheers!
Jim
As the people that work at the company change and replace pages, we've ended up with a few empty categories which I don't notice.
So, I thought it would be better to first check if the category has items, then produce the heading and link list.
The code I've started with so far, is:
Code: Select all
{products_getcategory category='2015-YachtRacing-WholeBoatCaribbeanRacing' assign='tmp'}
{if tmp !=''}
<h2>Caribbean Racing (Whole Boat)</h2>
{Products category='2015-YachtRacing-WholeBoatCaribbeanRacing' sortby='weight'}
{/if}
What do I need to do to make it effectively check if that category has items, and only produce the following code if it does?
Cheers!
Jim