[ic] Subcategories display

Mike Heins mikeh@minivend.com
Mon, 28 Aug 2000 19:39:43 -0400

Quoting Samvel Kocharjan (design@bluestar.ru):
> Hi All!
> May be it's dummie question and I still don't understand philosophy of IC
> but plz, plz help me.
> I wanna make catalog of products with categories, subcategories and may be
> sub-sub-categories (2-4 levels deep). Items will be available at all levels
> of catalog. How to display this catalog step-by-step.
> For example, when user click on "level 1" system display items which belong
> to this level and in some area of the page display available sub-levels.

The way I have done this in the past is to make a field called "hierarchy"
which is indexed and parsed during a search. For example:

 hierarchy	code
Art:Renaissance	99-001
Art:Surrealists	00-404
Art:Surrealists:European	00-343
Art:Surrealists:European	00-344
Art:Surrealists:American	19-203
Art:Surrealists:American	19-204

When the search is done, you can read the hierarchy field and break
down the hierarchy with embedded Perl and/or usertags. It will cause
the 00-404 SKU to be displayed on the search page, with links to further
categories. I will send you a URL separately which shows this, but cannot
answer any questions.

NOTE: Both the exloding left-side list and the hierarchical list use this index.

UserTag hierarchy Order path joiner profile
UserTag hierarchy PosNumber 3
UserTag hierarchy Routine <<EOF
sub {
    my ($input, $joiner, $profile) = @_;
    $joiner = ':' unless $joiner;
    $profile = 'guide' unless $profile;
    $input =~ s/^\s+//;
    $input =~ s/\s+$//;
    $input =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/chr(hex($1))/eg;
    my ($search, $bit, $anchor, $out);
    $out = Vend::Interpolate::tag_page('index');
    $out .= "Top</A>:";
    my @levels;
    @levels = split /:/, $input;
    my $last = pop(@levels);
    foreach $bit (@levels) {
        $search .= $joiner if $search;
        my $string = $bit;
        $string =~ s/(\W)/'%' . sprintf ('%02x', ord($1))/eg;
        $search .= $string;
        $anchor = 'scan/dl=';
        $anchor .= $search;
        $anchor .= "/mp=$profile";
        $anchor = Vend::Util::vendUrl($anchor);
        $out .= qq{<A HREF="$anchor">$bit</A>$joiner};

    $out .= $last;

(Originally done with help of Bob Jordan of Akopia.)

I don't have time to go into this further, but an upcoming release with
have a template "Buyer's Guide" which has those Yahoo-style categories.

Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.8220 fax 7501 <heins@akopia.com>

Unix version of an Outlook-style virus:
It works on the honor system. Please forward this message to everyone
you know, and delete a bunch of your files at random.