Forums / Setup & design / category - subcategory problem

category - subcategory problem

Author Message

Alessandro Cipriani

Monday 19 April 2004 2:23:03 am

hi all
i've this problem:
the user of my site will be categorized with two parameters, the second linked to the first in this way (either are select attribute):
cat1
-subcat11
-subcat21
-subcat31
cat2
-subcat21
-subcat22

and so on

in such an organization i'd like to avoid any error (like to have a customer of category 1 and subcategory 21) during the user registration.
the simplest way i thought was to write a javascript that loads only the appropriate values on the 2nd select one a choice on the first one is made. but i've problem with javascript function and i don't know if it's the right choice.

is there some built in mechanism to solve this problem?

best regards
alessandro

Gunnstein Lye

Monday 19 April 2004 7:24:45 am

If I understand you correctly, you don't need to store the first parameter. If you have stored subcat21, then you know that the first parameter must be cat2. No need to store both.

Alessandro Cipriani

Tuesday 20 April 2004 12:14:56 am

hi Gunnstein,
yes, i could do it,
but our customer asked two combos exactly in the way i explained in my first post.
so, before call him to tell that it's not possible, i wonder if there is a way to do what he wants.
also i tried to insert some javascript code inside the register.tpl file but, as any attribute is loaded programmatically, i'll have to change the entire code of the file.

is there any alternative way?
best regards
alessandro

Gunnstein Lye

Tuesday 20 April 2004 12:40:48 am

You can of course have two combo boxes, but you only need to store the second one. You can use the first one only to choose the right content for the second one (with javascript).

I suggest you use alternative attribute views, for instance:

(in register.tpl)
{attribute_edit_gui view="myspecialjavascript" attribute=$myattributelist.myattribute}

Now, create your special attribute in mydesign/content/datatype/edit/myspecialjavascript/ezselection.tpl
(if your attribute is an ezselection, of course.)

This way you don't have to have the same template for all attributes of the same type.