Gossamer Forum
Home : Products : Gossamer Links : Discussions :

categories in 2 different boxes?

Quote Reply
categories in 2 different boxes?
Hello.

Is it possible to divide categories in 2 different boxes?

I have City-Categories and Shop-Categories.

Now I want divide them.

Shopping:
------------------------------
Shop Cat Shop Cat
Shop Cat Shop Cat
Shop Cat Shop Cat
-----------------------------

City:
----------------------------
City Cat City Cat
City Cat City Cat
City Cat City Cat
---------------------------
Quote Reply
Re: [Knubbel] categories in 2 different boxes? In reply to
Hi,

Is this on the homepage, or category pages?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] categories in 2 different boxes? In reply to
It is on the categories page.

I gave the categories a field in the database with a "Yes" and a "No".
Quote Reply
Re: [Knubbel] categories in 2 different boxes? In reply to
Hi,

Well, it can be done with a global - but its a little tricky in terms of getting them in 2 columns (putting them in a single column is a piece of cake)

get_2_types_cats
Code:
sub {

my $tbl = $DB->Table('Category');
$tbl->select_options('ORDER BY Name ASC');

my (@loop,@loop2);
my $sth = $tbl->select( { FatherID => $_[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};
if ($hit->{YourField} eq "Yes") {
push @loop, $hit;
} else {
push @loop2, $hit;
}
}

return { Category_Loop_1 => \@loop , Category_Loop_2 => \@loop2 }

}

CHANGE THE BIT IF RED TO THE NAME YOU GAVE YOUR FIELD!

..call with this in category.html

Code:
<%get_2_types_cats($ID)%>

<%if Category_Loop_1.length%>
<h2>Categories with "Yes"</h2>
<%loop Category_Loop_1%>
<%include subcategory.html%>
<%endloop%>
<%endif%>

<%if Category_Loop_2.length%>
<h2>Categories with "No"</h2>
<%loop Category_Loop_2%>
<%include subcategory.html%>
<%endloop%>
<%endif%>


This will ONLY put them in a single column though - i.e

<h2>Categories with "Yes"</h2>
xx
xx
xx
xx
xx

<h2>Categories with "No"</h2>
xx
xx
xx
xx
xx

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] categories in 2 different boxes? In reply to
It runs.

Very great!

I have changed:
my $tbl = $DB->Table('Category');

to:
my $tbl = $DB->table('Category');


Thanks.
Knubbel.
Quote Reply
Re: [Knubbel] categories in 2 different boxes? In reply to
Hi,

Glad to hear it =)

Sorry about the typo - do that a lot when rushing through making globals - things like fetchrow_Hashref, ->Table ->Select etc - bit annoying sometimes - and don't always pick them up until they are tested <G>

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates