Gossamer Forum
Home : Products : Gossamer Links : Discussions :

2 sets of Categories

Quote Reply
2 sets of Categories
I am looking to display categories on leftside bar:

For an example on a subcategory Page it lists all the sub categories that have a prority

This is what i need:

Priority Categories:

List all categories that have a priority

Other Categories:

List all other categories

Can anyone help me out with this?
Jason Bishop

Last edited by:

netnow: Jan 24, 2009, 1:59 PM
Quote Reply
Re: [netnow] 2 sets of Categories In reply to
Hi,

Add a new field via Database > Category > Properties > Add Column, called CatIsPriority (INT SELECT 1/0Yes/No)

Then, you can use this global:

sort_out_cat_loops
Code:
sub {

my $father_id = $_[0] || 0;
my $tbl = $DB->table('Category');
$tbl->select_options('ORDER BY Name');

my (@norm_loop, @priority_loop);

my $sth = $tbl->select( { FatherID => $father_id, CatIsPriority => 1 } ) || die $GT::SQL::error;

# get priority loop of cats
while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $hit->{Full_Name} ) . "/" . $CFG->{build_index};
push @priority_loop, $hit;
}

# now get normal categories
my $sth = $tbl->select( { FatherID => $father_id, CatIsPriority => 0 } ) || die $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $hit->{Full_Name} ) . "/" . $CFG->{build_index};
push @norm_loop, $hit;
}

return { priority_loop => \@priority_loop, norm_loop => \@norm_loop };
}

Then call with:


Code:
<%sort_out_cat_loops($category_id)%>

<%if priority_loop.length%>
<%loop priority_loop%>
<%include subcategory.html%>
<%endloop%>
<%endif%>


<%if norm_loop.length%>
<%loop norm_loop%>
<%include subcategory.html%>
<%endloop%>
<%endif%>


Untestd, but should work =)

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!