Gossamer Forum
Quote Reply
loop selected_cats
Hi

In include template..

Can the <%~loop selected_cats%> be restricted to show only one top category and all its subs and not load the whole category structure.
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] loop selected_cats In reply to
Hi,

Which template?

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!
Quote Reply
Re: [Andy] loop selected_cats In reply to
In add.html
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] loop selected_cats In reply to
Hi,

I've tried doing this before, and couldn't come up with a working solution - so no, I don't think so.

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!
Quote Reply
Re: [katabd] loop selected_cats In reply to
Hi there ^_^ ,

I have a global here that might be able to help.

category_selector

Code:
sub {
my $catid = shift;
my $return_cats = qq|<select name="CatLinks.CategoryID">|;
$return_cats .= "<option></option>";
$return_cats .= getChildren($catid);
$return_cats .= "</select>";
return $return_cats ;

sub getChildren{

my $catid = shift;
my $table = $DB->table('Category');
my $return = "";
$table->select_options ('ORDER BY Full_Name ASC');
my $cond = GT::SQL::Condition->new('FatherID','=',$catid);
my $sth = $table->select( $cond );
while (my $hit = $sth->fetchrow_hashref) {
$return .= "<option value=\"" . $hit->{ID} . "\"";
$return .= ">" . $hit->{Full_Name} . "</option>";
$return .= getChildren($hit->{ID});
}

return $return;
}
}



This should generate a selectbox of the selected category and its children.
You can use it like this: <%category_selector($ID_of_top_category)%>
Just replace "$ID_of_top_category" with the id of the category you want to be loaded.

A word of warning though... the select box is generated using recursion, and I haven't done that in a while.
The global is also not tested... yet anyway. Feel free to modify it as you wish, as it doesn't seem to be precisely what you are looking for...

Hope it helps ^_^


Sacrifice is not about what you lose,
it is about what you gain in the process.

Last edited by:

EZFrag: Nov 6, 2008, 12:56 AM