Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Form display based on the user name

Quote Reply
Form display based on the user name
I am trying to give access to a particular user to add links in one category and its subcategories. So that new form only be displayed if that user logins. (The new form contains extra 3 form fields that I will create for him.)

<%if Username eq xxxxx%>
<%include include_my_new_form.html%>
<%else%>
<%include include_form.html%>

But how to pull login session from the database or how to get it work?
Quote Reply
Re: [hegu] Form display based on the user name In reply to
You can use the user.Username variable.

Adrian
Quote Reply
Re: [brewt] Form display based on the user name In reply to
So like this?

<%if user.Username eq xxxxx%>
<%include include_my_new_form.html%>
<%else%>
<%include include_form.html%>

thanks.
Quote Reply
Re: [hegu] Form display based on the user name In reply to
Yup

Adrian
Quote Reply
Re: [brewt] Form display based on the user name In reply to
Thanks Adrian!

I am trying to dislay an error message 'You are not allowed to submit to this category' for certain categories for users.

I tried this. (It is from my 'mint' templates) Not working.

<%category_template_form('set', 'include_error_page.html', '262')%>
<%category_template_form('set', 'include_error_page.html', '263')%>
<%category_template_form('set', 'include_error_page.html', '270')%>
<%set form = category_template_form($ID)%>
<%if form%>
<%form%>
<%else%>
<%include include_form.html%>
<%endif%>

What is wrng about it?

thanks.
Quote Reply
Re: [hegu] Form display based on the user name In reply to
I searched the forum.

http://www.gossamer-threads.com/...de_form.html#p299172

I used first example:

<%if ID = '270'%>
<%include include_error_page.html%>
<%else%>
<%include include_form.html%>
<%endif%>

It is working great.

Thanks!
Quote Reply
Re: [hegu] Form display based on the user name In reply to
I am trying to add multiple categories, but not working. One category is working.

THIS IS WORKING:

<%if ID = '270'%>
<%include include_error_page.html%>
<%else%>
<%include include_form.html%>
<%endif%>

THIS IS NOT WORKING:

<%if ID = '270','283','284','290'%>
<%include include_error_page.html%>
<%else%>
<%include include_form.html%>
<%endif%>

Why? Syntax wrong? thanks.
Quote Reply
Re: [hegu] Form display based on the user name In reply to
You need:

<%if ID = '270' or ID = '283' or ID = '284' or ID = '290'%>

Hope that helps.

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] Form display based on the user name In reply to
Thanks. I will try that out.
Quote Reply
Re: [Andy] Form display based on the user name In reply to
Andy wrote:
You need:

<%if ID = '270' or ID = '283' or ID = '284' or ID = '290'%>

Hope that helps.

Cheers
Andy,

There are 30 sub categories under one category. So is there anyway to keep parent ID and its subcategory IDs without actually listng bunch of them?

<%if ID = '270' or ID = 'its subcategories'%>

thanks.
Quote Reply
Re: [hegu] Form display based on the user name In reply to
Hi,

Mmm, not easily - would be better just to list the ID numbers.

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] Form display based on the user name In reply to
Code:
<%if ID = '270' or ID = '283' or ID = '284' or ID = '290'%>

It is difficult to list 900 subcategories this way. Crazy

Any help please?
Quote Reply
Re: [hegu] Form display based on the user name In reply to
Is it only one category you don't wanna let them submit to? If so, try using a new global:

check_if_can_submit
Code:
sub {
my $category_name = $DB->table('Category')->select( ['Full_Name'], { ID =>$_[0] } )->fetchrow;
if ($category_name =~ /^Category Name Your Dont want to let them add to/) {
return { cant_add => 1 }
}
}

..then call with:
Code:
<%check_if_can_submit($ID)%>
<%if cant_add%>
They can't add here
<%else%>
They can add here
<%endif%>

Just change the text in "red" to the root-category you don't want them to be allowed to add to (this will also stop sub-categories)

Untested, but should work fine.

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] Form display based on the user name In reply to
Quote:
Is it only one category you don't wanna let them submit to?

No. I am trying this:

<%if ID = '270' or All_its_subcategories%>
include_form_2.html
<%else%>
<%if ID = '271' or All_its_subcategories%>
include_form_3.html
<%if ID = '275' or All_its_subcategories%>
include_form_4.html
<%endif%>

But each parent category has around 60 subcategories. Crazy So I want to include all subcategories instead of listing those 60 of them under each category.
Quote Reply
Re: [hegu] Form display based on the user name In reply to
How about trying it other way around.

1. Setup a new category field, lets call it 'allow_add'. With options Yes/No
2. Now assuming you have already created the categories and there are more categories where you want to allow users to be able to add listing, have 'Yes' value as default.
3. Modify the value to 'No' under 'Edit Categories' for each category, you don't want to allow end users to add listing.
4. Under include.html setup tags li

<%if alow_add eq 'Yes'%>
<%include add.html%>
<%else%>
Sorry you can't add listing here.
<%endif%>

In addition, if you have different type of froms for different type of category, you can setup more options than Yes/No for allow_add category field and just change the if/elseif options under add.html and it should do the trick.

Hope this helps.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Form display based on the user name In reply to
Hi, Why I want the following format is: I need this for display other type of content too based on category and its subcategories. Not only the simple form.

<%if ID = '270' or All_its_subcategories%>
include_form_2.html
<%else%>
<%if ID = '271' or All_its_subcategories%>
include_form_3.html
<%if ID = '275' or All_its_subcategories%>
include_form_4.html
<%endif%>

thanks
Quote Reply
Re: [hegu] Form display based on the user name In reply to
I don't know if you can use <%if ID = '270' or All_its_subcategories%> or not, however if you use the suggested option, you can use any info on submission page as desired or just display info without any form.

<%if alow_add eq 'Yes'%>
<%include anything.html%>

<%else%>
Sorry you can't add listing here.
<%endif%>

Hope this helps.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Form display based on the user name In reply to
Hi,

NOt only on the form submission page, I need this <%if ID = '270' or All_its_subcategories%> tag for other things too. But I am not sure how to pull all subcategories under that parent category.

thanks for your time.
Quote Reply
Re: [hegu] Form display based on the user name In reply to
You're not being very specific. If its for a place where you have access to the $ID tag, you could load the category name with:

load_cat_name
Code:
sub {
return $DB->table('Category')->select( ['Full_Name'], { ID => $_[0] } )->fetchrow;
}

..then call with;

Code:
<%set Full_Name =load_cat_name($ID)%>
<%if Full_Name istart = "Test Category/Something"%>
show one form
<%elsif Full_Name istart = "Another Test Category"%>
another form
<%else%>
something else
<%endif%>

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] Form display based on the user name In reply to
Ooops ... Anydy. I am not talking the form display only. What I am trying to do is this:

http://www.gossamer-threads.com/...0and%20subcategories

thanks.