Gossamer Forum
Home : Products : Gossamer Links : Discussions :

[HELP] :: How to 'not' display categories with 0 Links inside?

Quote Reply
[HELP] :: How to 'not' display categories with 0 Links inside?
I was wondering if there was any way/global so that categories without any links in them won't be displayed in category.html?

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [HELP] :: How to 'not' display categories with 0 Links inside? In reply to
Hi,

There isn't really a simple solution to that. You can however edit /admin/Links/Build.pm, and change (in sub build_category {).

REMEMBER: You will need make these changes every time you upgrade, or apply bug fixes that apply to the Build.pm file.

Find:

Code:
if ($CFG->{build_category_yahoo}) {

..and add just ABOVE it:

Code:
my $cond = new GT::SQL::Condition;
$cond->add('FatherID','=',$category->{ID});
$cond->add('Number_of_Links','>',0);
$cond->bool('AND');

Then, find:

Code:
my @subcat_ids = $cat_db->select(ID => { FatherID => $category->{ID} })->fetchall_list;

..and change to:

Code:
my @subcat_ids = $cat_db->select(ID => $cond )->fetchall_list;

..and also find:

Code:
$sth = $cat_db->select({ FatherID => $category->{ID} });

..and change to:

Code:
$sth = $cat_db->select( $cond );

That should work fine (I've PM'ed you the edited file, just to make it easier - just didn't wanna post the whole thing here, for obvious reasons =))

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [HELP] :: How to 'not' display categories with 0 Links inside? In reply to
Andy this is dirty ;)

There is an easy way, just edit subcategory.html, and put

<%if Number_of_Links > 0%> in the begining and <%endif%> at the end, and voila ;) job is done without altering the core code.

Just like this:
Code:
<%if Number_of_Links > 0%>
<dt><a href="<%escape_html URL%>"><%if RelationName%><%RelationName%><%else%><%Name%><%endif%><%if Related%>@<%endif%></a> (<%Number_of_Links%>)<%if Has_New_Links eq 'Yes'%> <span class="new-item"><span>new</span></span><%endif%><%if Has_Changed_Links eq 'Yes'%> <span class="updated-item"><span>updated</span></span><%endif%></dt>
<%if Description%><dd><%Description%></dd><%endif%>
<%endif%>

Cheers,
Boris

Facebook, Twitter and Google+ Auth for GLinks and GCommunity | reCAPTCHA for GLinks | Free GLinks Plugins
Quote Reply
Re: [eupos] [HELP] :: How to 'not' display categories with 0 Links inside? In reply to
Hi,

True, but then you end up with gaping holes where those categories should be :P Its always better to take the categories out of the equation, before they get to the template (especially in the older versions, as you would have entirely empty <td></td> from the <%category%> tag - obviously more in LSQL, than GLinks)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [HELP] :: How to 'not' display categories with 0 Links inside? In reply to
Yes I agree for the older versions your aproach is better Wink

But in GLinks 3.x this works better, and leaves no holes Tongue

I have tested it Cool works fine in my end.

Cheers,
Boris

Facebook, Twitter and Google+ Auth for GLinks and GCommunity | reCAPTCHA for GLinks | Free GLinks Plugins
Quote Reply
Re: [eupos] [HELP] :: How to 'not' display categories with 0 Links inside? In reply to
Hi Andy, thanks for the info, I am gonna try this (but am hoping to solve this without having to edit any core files).....

Hi Eupos,

Andy is right, about gaps in design. I have 8 main category on my test site. Now only 3 of these categories have links in them (1 link in each). Few days back I used the <%if Direct_Links > '0'%> tab instead of <%if Number_of_Links > '0'%> (but they both works the same ;) ) and here is the output (just tested it again with Number_of_Links)

Category 1..................Category 5
................................Category 7

As even tho the empty categories are not being shows, it still keeps the category within its column and hence can make the site look totally off the balance. (Category 5 and Category 7 are in right column, while Category 1 is in left column)

I don't think working on subcategory.html could fix this, but if there was a way to use some global in category.html, so that it won't request subcategory.html if there is no links under particular category.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [HELP] :: How to 'not' display categories with 0 Links inside? In reply to
Hi,

Quote:
Andy is right, about gaps in design. I have 8 main category on my test site. Now only 3 of these categories have links in them (1 link in each). Few days back I used the <%if Direct_Links > '0'%> tab instead of <%if Number_of_Links > '0'%> (but they both works the same ;) ) and here is the output (just tested it again with Number_of_Links)

Category 1..................Category 5
................................Category 7

As even tho the empty categories are not being shows, it still keeps the category within its column and hence can make the site look totally off the balance. (Category 5 and Category 7 are in right column, while Category 1 is in left column)

I don't think working on subcategory.html could fix this, but if there was a way to use some global in category.html, so that it won't request subcategory.html if there is no links under particular category.

Thought I was =) (either that, or I'm going mad :P)

Unfortunately - when a page is rendered, I don't believe there are any hooks you can link into, to edit the "conditions" passed in, for grabbing the appropriate categories. I tried a while back (on one of my own sites), and after hours and hours of trying to figure it out, I came to the conclusion, the only way to do it - is by editing the core code :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!