Gossamer Forum
Home : Products : Gossamer Links : Discussions :

add only to certain categories- revisited

Quote Reply
add only to certain categories- revisited
I use <%if AddOK eq 'Yes'%> to restrict the ability to add links to certain category pages- the ADD link only appears in the menu if this condition is true.

However, now my site is about to go public, I want to hide the categories that are empty. In order to do this, I need the ADD link to appear on all pages, and to reinstate the db_gen_category_list to Yes.

I have tried to control which categories appear by using the <%if AddOK eq 'Yes'%> condition in the include_form.html but no categories are displayed.

Having searched the forums, I cannot find a solution to this problem, can anyone help?

Thanks
Alba
Quote Reply
Re: [Alba] add only to certain categories- revisited In reply to
It seems you have a good solution - why are you changing back to putting the Add link in all categories?

The data from the Category table is not available on the add page so doing it the other way would involve writing a global to pull the data from the table which you could then use in the template.
Quote Reply
Re: [afinlr] add only to certain categories- revisited In reply to
The reason for wanting to change it is very simple. The website now has enough information in it to 'go live' but there are certain categories that are still empty. I know myself, when looking at other websites, that there is nothing more annoying than categories that are empty- so I want to hide them.

Doing this means I must have a drop down list of categories on the addition form.

Alba
Quote Reply
Re: [Alba] add only to certain categories- revisited In reply to
OK - I understand the problem now.

You need a new global - I think it needs to be something like this - call it allowed_cats and then instead of <%Category%> in your add form use <%allowed_cats%>

sub{
my $category;
my $db = $DB->table('Category');
my $sth = $db->select ( {AddOK=>'Yes'}, ['Full_Name','ID'] );
while (my ($name,$id) = $sth->fetchrow_array){
$category .= "$name <input type=hidden name='CatLinks.CategoryID' value=$id>";
}
return $category;
}