[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Tree and matchlimit - how add matchlimit to tree results?
Hi All
I'm using Mike's Tree. One of the things I noticed is that when you click a category, the results show all subcats and products under that top category.
The problem is that there is no spanning of the results.html page. All you get is a monster long list of products.
Is there a way to plug in a matchlimit of "10", let's say, to spread out the results?
Here is the code for tree_build.html:
<!-- BEGIN CONTENT -->
[perl tables="products tree"]
my $db = $Db{products};
my $ary = $db->query('select sku,comb_category from products');
my $out = '';
my $code = '00000';
my $cc = '0000';
my %done;
my @levels;
foreach $row ( @$ary) {
my ($sku, $cat) = @$row;
next if $done{$cat};
my $parent = 'TOP';
my @parts = split /:/, $cat;
my $combname = '';
for( my $i = 0; $i < @parts; $i++) {
my $name = $parts[$i];
my $comb = join ":", @parts[0 .. $i];
my $level = $levels[$i] ||= {};
if(! $level->{$name}) {
$level->{$name} = [ ++$code, $parent, ++$cc, $name, $comb ];
$parent = $cc;
}
else {
$parent = $level->{$name}->[2];
}
}
}
my $tdb = $Db{tree};
$tdb->query('delete from tree');
my @flds = qw/parent_fld child_fld name category/;
my $count++;
for(@levels) {
my $hash = $_;
for(sort keys %$hash) {
my $rec = $hash->{$_};
my $code = shift @$rec;
$tdb->set_slice($code, \@flds, $rec);
$count++;
}
}
return $count;
[/perl]
<!-- END CONTENT -->
Here is tree_populate.html:
<!-- BEGIN CONTENT -->
[flag type=write table=products]
[perl tables=products]
my $db = $Db{products};
my $ary = $db->query('select sku,prod_group,category from products');
my $out = '';
foreach $row ( @$ary) {
my ($sku, $pg, $cat) = @$row;
$db->set_field($sku, 'comb_category', "$pg:$cat")
and $out .= "$sku = $pg:$cat<br>\n";
}
return $out;
[/perl]
<!-- END CONTENT -->
And, here is tree_display.html:
<!-- BEGIN CONTENT -->
<P>
[page href=@@MV_PAGE@@ form="explode=1"]Explode tree[/page]
[page href=@@MV_PAGE@@ form="collapse=1"]Collapse tree[/page]
</P>
<table>
[if cgi toggle]
[calc]
my $par = '[data table=tree col=parent_fld key="[cgi toggle]"]';
delete $Scratch->{memo} if $par eq 'TOP';
return;
[/calc]
[/if]
[tree start=TOP
table=tree
master=parent_fld
subordinate=child_fld
autodetect=1
toggle=toggle
memo=memo
collapse=collapse
explode=explode
spacing=4
]
<tr>
<td>
[if-item-param mv_level]
[item-calc]
return ' ' x [item-param mv_spacing];
[/item-calc]
[/if-item-param]
[if-item-param mv_children]
<A HREF="[area href=@@MV_PAGE@@ form='toggle=[item-param code]']">
[item-calc] $Scratch->{memo}{'[item-code]'} ? '-' : '+' [/item-calc]
</A>
[/if-item-param]
[page search="
fi=products
st=db
bs=1
tf=comb_category
sf=comb_category
se=[item-param category]
"][item-param name]</A>
</td>
</tr>
[/tree]
</table>
<!-- END CONTENT -->
Thanks very much.
--
_______________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
Win the Ultimate Hawaiian Experience from Travelocity.
http://ad.doubleclick.net/clk;4018363;6991039;n?http://svc.travelocity.com/promos/winhawaii/