Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Hiding form fields based on current category

Quote Reply
Hiding form fields based on current category
Hiya!

I got a tip a while back that I could use IF to determine if a form field should be shown on my include_form.html template.
I've tried it and it didn't work. What I tried was:

<%if Category eq 'SomeCat'%>
form field code
<%endif%>

First of all, why doesn't this work? Secondly, how does category vs sub-category factor into this? If I'm in the category Cat1->Cat2->Cat3, I would want the IF to count for the parent category and all sub-categories. Any ideas? :)
Cheers,
Hans Jørgen
www.dicereviews.com
Quote Reply
Re: [perhaps] Hiding form fields based on current category In reply to
Probably because there is no tag named 'Category' available by default. Try 'Name' or 'Full_Name'. As for the sub-category thing, you can do something like <%if Full_Name starts 'SomeCat/'%>

Adrian
Quote Reply
Re: [brewt] Hiding form fields based on current category In reply to
Hi again!

Tried a number of variations to get this to work, but no matter how I made the IF syntax, the field woulden't show.
Looking at the database, the Full_Name field contains nothing for categories, but Name does. Name is also used by
the User table. Could it be that my IF statement looks at the User.Name column instead of Category.Name column?

Can I specify which table when using tags? <%If Category.Name eq 'Movies'%> ?
Cheers,
Hans Jørgen
www.dicereviews.com
Quote Reply
Re: [perhaps] Hiding form fields based on current category In reply to
Hmm..Still not getting anywhere with this.

Someone who looked at it said that in the include_form.html template what category you choose to add a product to is added by a javascript, so that the page woulden' know what category is chosen. Could the problem lie there?
Cheers,
Hans Jørgen
www.dicereviews.com
Quote Reply
Re: [perhaps] Hiding form fields based on current category In reply to
*Sigh* Changed from Ajax based category chooser to the version where the category is the one you were in when you chose to add a link. Did a tag dump and saw that Full_Name is used and what value a given category had. I tried all kind of variants for a IF statement, but <%if Full_name eq 'Category'%> is just not working. :(
Cheers,
Hans Jørgen
www.dicereviews.com
Quote Reply
Re: [perhaps] Hiding form fields based on current category In reply to
You have <%Full_name - I'm guessing this is a typo?

Try this

Category: <%Full_Name%>
<%if Full_Name eq 'Category'%>Do stuff<%endif%>

Then you can see what the value for Full_Name is at the point where you are trying to use it.

Last edited by:

afinlr: Mar 22, 2007, 11:56 AM
Quote Reply
Re: [perhaps] Hiding form fields based on current category In reply to
Sorry, I originally misread your first post. The add form never fetches the category information unless you do it yourself, so you'll never get a match on Full_Name. You'll only be able to use the ID that's passed in (you can write a global to fetch the Full_Name based on that though).

Adrian