Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Subcategories by ID?

(Page 1 of 2)
> >
Quote Reply
Subcategories by ID?
Hello.

Is it possible to show subcategories by ID.

I want in category "50" all subcategories from category "13" display.


<%loop category_loop%>
<%~include subcategory.html%>
<%~endloop%>
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Sorry - not too sure what you are trying to do.

Are you asking for a global, which will get upto 50 categories, from the main category (ID: 13) .. and give you a loop, so you can show them on your 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] Subcategories by ID? In reply to
Mhhh.

I want display in a selected categorie subcategories from a other catergory.

Example:
I have a category like: Home/Cars/Mistubishi

and want display in this category all subcategories from this
category:

Home/Cars/Nissan

Is it possible to get the subcategories with this:
<%loop category_loop%>
<%~include subcategory.html%>
<%~endloop%>

Knubbel
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Ok you still need to clear things up - as I'm not really sure what you want to do still :P

So - the cateogry Cars/Mistubishi is ID 13 .. right?


..and on this category:

Cars/Nissan

..you want to show all the categires frin the Category ID 13 ???

If so, thats not really gonna be very easy to do :/

Quote:
<%loop category_loop%>
<%~include subcategory.html%>
<%~endloop%>

That loop only has values of categories, that exist in the category you are viewing - so won't be any help, if your trying to do what I think you are.

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] Subcategories by ID? In reply to
Yes, 13 is my current category and I want display the subcategories of 50.

I thought there would be a way to give the loop the value 50...
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Getting the sub-categories is simple - you just do it with a global:

get_cats_in_other
Code:
sub {

my $cat = $_[0];
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;

my $db_obj = $DB->table('Category');
$db_obj->select_options ('ORDER BY Full_Name DESC');

my $sth = $db_obj->select ( GT::SQL::Condition->new('ID', 'IN', $all_ids) ) || die $GT::SQL::error;

my @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 @cats, $hit;
}

return { cats_loop => \@cats }

}

(totally untested ;))

..call with:

Code:
<%get_cats_in_other(50)%>
<%if cats_loop.length%>
<%loop cats_loop%>
<%include subcategory.html%>
<%endloop%>
<%endif%>

That will work - *but* I'm not sure if it will work in the way you want - as it will show on ALL categories - unless you have a different category.html for this particular category.

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

Last edited by:

Andy: Jul 7, 2008, 8:09 AM
Quote Reply
Re: [Andy] Subcategories by ID? In reply to
Oh thanks.

I've changed the red text. Is that right?


sub {

my $cat = $_[0];
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;

my $db_obj = $DB->table('Category');
$db_obj->select_options ('ORDER BY Full_Name DESC');

my $sth = $db_obj->select ( GT::SQL::Condition->new('ID', 'IN', $all_ids) ) || die $GT::SQL::error;

my @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 @cats, $hit;
}

return { cats_loop => \@cats }

}


Now I tried your script. I cann see the links Cool
but under any link is this text:
Error: Unmatched endif/endifnot/endunless tag
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Now it runs!!!

<%get_cats_in_other(50)%>
<%if cats_loop.length%>
<%loop cats_loop%>
<%include subcategory.html%>
<%~endloop%>
<%endif%>

Thanks, Knubbel
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
sorry, my fault - please use the updated global (in my post above), and also the new tempalte code Smile

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] Subcategories by ID? In reply to
It works fine. Cool

I have only one little problem:
The Fathercategory (50) is displayed too. Is it possible to remove them?
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Cool Cool

To remove the category ID 50, just remove this line from the global:

Code:
push @$all_ids, $cat;

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] Subcategories by ID? In reply to
Thanks you are great.

Knubbel
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
The script from yesterday works very fine.

Now I have a new question.
Is it also possible to get a direct link to "cat 50" with the global?


<%get_cats_in_other(50)%>
<a href="<%escape_html URL%>"><%if RelationName%><%RelationName%><%else%><%Name%><%endif%><%if Related%>@<%endif%></a>
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Knubbel wrote:
Now I have a new question.
Is it also possible to get a direct link to "cat 50" with the global?

<%get_cats_in_other(50)%>
<a href="<%escape_html URL%>"><%if RelationName%><%RelationName%><%else%><%Name%><%endif%><%if Related%>@<%endif%></a>

Not sure what you mean?

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] Subcategories by ID? In reply to
Oh my bad English...Blush

At first I have a quetion to the script from yesterday.
Is it possible to limit the CatDepth of the displayed links.

The red cats should not be displayed.

Cat50/Cat/Cat/Cat/
Cat50/Cat/Cat/Cat/Cat/
Cat50/Cat/Cat/Cat/




Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Ok, so you just want the ones that are a single depth - inside the category you are selecting. Try this:

Code:
sub {

my $cat = $_[0];
my $db_obj = $DB->table('Category');
$db_obj->select_options ('ORDER BY Full_Name DESC');

my $sth = $db_obj->select ( FatherID => $_[0] ) || die $GT::SQL::error;

my @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 @cats, $hit;
}

return { cats_loop => \@cats }

}

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] Subcategories by ID? In reply to
Oh, it shows many, many... links to "cat 50".

What did I make wrong?

I have insert this:
Code:
sub {

my $cat = $_[0];
my $db_obj = $DB->table('Category');
$db_obj->select_options ('ORDER BY Full_Name DESC');

my $sth = $db_obj->select ( FatherID => $_[0] ) || die $GT::SQL::error;

my @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 @cats, $hit;
}

return { cats_loop => \@cats }

}
in:
get_cats_in_other

Knubbel
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Can you show me an example page, where I can see?

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
Post deleted by Knubbel In reply to
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Mmm. your site won't load for me :(

Can you make a screenshot, and upload it here, so I can see whats actually happening?

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
Post deleted by Knubbel In reply to
Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

Mmm.. that is very odd. Could you send over GLinks admin details, so I can try and debug? Not a lot I can tell by just looking at the output :(

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] Subcategories by ID? In reply to
Hi,

Should be fixed now :)

The error was with this line:


Code:
my $sth = $db_obj->select ( FatherID => $_[0] ) || die $GT::SQL::error;

..it needed to be:


Code:
my $sth = $db_obj->select ( { FatherID => $_[0] } ) || die $GT::SQL::error;

I've tested it on your site, and it works perfectly now Smile


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] Subcategories by ID? In reply to
I hope this is my last question:

Above the cats from the different category
I want set a link to the different category.

Like this:

Categories in Cat55:

- SUBCAT FROM Cat55
- SUBCAT FROM Cat55
- SUBCAT FROM Cat55

Quote Reply
Re: [Knubbel] Subcategories by ID? In reply to
Hi,

If your trying to do what I think you are - you should just be able to use:

Code:
<%get_cats_in_other(55)%>
<%if cats_loop.length%>
<%loop cats_loop%>
<%include subcategory.html%>
<%~endloop%>
<%endif%>

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
> >