[ic] How to create [same name] subcategories

Mike Heins mheins@redhat.com
Tue, 3 Apr 2001 14:00:37 -0400


Quoting Gina K. Anderson (gina@sitediva.com):
> |How can I create subcategories?
> 
> I still haven't bee able to figure out this little problem:
> 
> Dog Products 	(main)
> 	Food		(sub)
> 	Collars	(sub)
> 	Toys		(sub)
> 
> Cat Products	(main)
> 	Food		(sub)
> 	Collars	(sub)
> 	Toys		(sub)
> 
> 
> I've pretty much thrown IC out of the loop because this is seems to be so
> difficult. Firstly, the admin needs to differentiate between the Dog Food and
> Cat Food, so a client can add products to either category without needing to
> make sure 'cat' or 'dog' is in the name of the product (so a search will turn up
> the right products-which doesn't always seem to work anyway).
> 
> There are lots of stores that have something like this in the admin:
> 
> Choose a category to add the product to:
> 
> [drop down box lists:]
> Dog Products
> Dog Products->Food
> Cat Products
> Cat Products->Food
> 
> It seems there is something in the data table structure that does not allow this
> to be done easily. Two people tried to help me out with this, but no solution
> seemed to work correctly.

Depends on your definition of easy.

1. Add a database field "prod_group" to products.

2. Populate "prod_group" with "Dog Products", etc.

3. Create a coordinated search:


	<A HREF="[area
		    href=scan 
		    search.1='
			    sf=prod_group
			    se=Dog
		    '
		    search.2='
			    sf=category
			    se=Collars
		']">Dog Collars</A>


If you want to build it automatically from Products, you can do:

[timed-build minutes=10 file=tmp/category_tree login=1]
<DL>
[loop
	prefix=group
	search="
		ra=yes
		un=yes
		rf=prod_group
		tf=prod_group
	"]
    <DT> [group-code] </DT>
    <DD>
	[loop
	    prefix=cat
	    search="
		    un=yes
		    co=yes
		    sf=prod_group
		    se=[group-code]
		    op=eq

		    rf=category
		    tf=category
	    "]
	<A HREF="[area
		    href=scan 
		    search.1='
			    sf=prod_group
			    se=[group-code]
		    '
		    search.2='
			    sf=category
			    se=[cat-code]
		    '
		]">[group-code]->[cat-code]</A><BR>
    [/loop]
    </DD>
[/loop]
</DL>
[/timed-build]

-- 
Red Hat, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <mheins@redhat.com>

If you think nobody cares if you're alive, try missing a couple of
car payments.  -- Earl Wilson