Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Limit Add To Last Category?

Quote Reply
Limit Add To Last Category?
Hi, does anyone know how to block users from adding to categories until they reach the end of the category tree? For example, if a category is...

this/is/the/example/category/tree

they cannot add anything between 'this' and 'category', only into the last one, being 'category'?.

I know there is a mod "Add/Mod_only_in_special_cats" which is probably what I need, but could it be done simpler using a <%if category%><%endif> on the 'add link'?

Anyone got something like that working?

Cheers

Regan.

Quote Reply
Re: Limit Add To Last Category? In reply to
I did a MOD to allow admin to turn submissions ON/OFF, see this thread:

http://www.gossamer-threads.com/...w=collapsed&sb=5

By default a new category has submissions turned ON, but you can turn them ON/OFF at will. In your case you can turn them all OFF except the ones at the end of the category tree's.

On the actual category pages there is no 'Submit' link unless it's been turned ON by admin, so your visitors can only submit to the 'allowed' categories.

All the best
Shaun

Quote Reply
Re: Limit Add To Last Category? In reply to
you beauty!

Cheers, I'll give it a go.

Regan.

Quote Reply
Re: Limit Add To Last Category? In reply to
Hi qango,

I've tried the mod and done everything as listed in it, but for some reason mines not recognising the <%if isSub eq 'Yes'%> in the header template to bring up the link. When I try <%ifnot isSub%> it comes up every time, which suggests when the template is being parsed it doesnt know what the 'isSub' is.

Any ideas on what I could be doing wrong? Or if there's any code that wasn't included in that mod post?

Cheers
Regan.

Quote Reply
Re: Limit Add To Last Category? In reply to
Regan,

Just to check;

You've created the isSub field in the categories table ...
You've updated nph-build.cgi to add the new field - $OUT{isSub} = $category_r->{'isSub'};
You've added the correct snippet for <%if isSub ....

Double-check to make sure all the code is OK, if you still can't get it going post a copy of the changes from your files so I can have a closer look - thanks.

All the best
Shaun

Quote Reply
Re: Limit Add To Last Category? In reply to
Hi Shaun,

This is what I've done so far...
Added to the category table as per the posting,
Column: isSub
Type: CHAR
Form Length: 3
Max Length: 3
Not Null: YES
Default Value: YES (people can submit as default)
Validation: YES|NO
Index Weight: 0

with capital YES|NO etc if that makes a difference?

This is copy/pasted straight out of the nph-build...

# Get the category info.

%OUT = (); # Start with a clean hash.
$OUT{category_id} = $category_r->{'ID'};
$OUT{category_name} = $category_r->{'Name'};
$OUT{header} = $category_r->{'Header'};
$OUT{footer} = $category_r->{'Footer'};
$OUT{meta_name} = $category_r->{'Meta_Description'};
$OUT{meta_keywords} = $category_r->{'Meta_Keywords'};
$OUT{description} = $category_r->{'Description'};
$OUT{random} = rand (10000);
$OUT{random1} = rand (10000);
$OUT{random2} = rand (10000);
$OUT{random3} = rand (10000);
$OUT{isSub} = $category_r->{'isSub'};

and this is the code I've put in the html...

<%if isSub eq 'Yes'%>
<a href="<%db_cgi_url%>/add.cgi?ID=<%category_id%>">Add Only in Category</a>
<%endif%>

I tried the html with a capital <%if isSub eq 'YES'%> but that didn't seem to make it come up either.

Do I need to re-create the def files or anything like that?

Thanks again,

Regan.

Quote Reply
Re: Limit Add To Last Category? In reply to
OK, code seems fine. Here's a couple of other things to check:

Have you changed any of the categories so that 'isSub' equals YES? If not, you'll need to change them.

Have you done a 'build' since you changed the code? If not, do one as it'll re-write your category pages using the updated version of the templates with the new 'isSub' details in (that may be the problem as I forgot to mention it in my original post - sorry - I've updated that thread with this addition!).

If you do a re-build and its still not working, maybe we should take it to email and work from there.

All the best
Shaun
webmaster@qango.com