Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Listing a categorys subcategories in home.htm

Quote Reply
Listing a categorys subcategories in home.htm
Hi,

I would like to show all subcategories to a certain category on the frontpage. There is only one level og subcategories in the category.

Does anyone know how to do that?

Cheers
Root
Quote Reply
Re: [rootdk] Listing a categorys subcategories in home.htm In reply to
Do you just want to show the list one level deep?

i.e;

Code:
Root
Cat 1
Cat 2
Cat 3
Cat 4
...etc

...or...

Code:
Root
Cat 1
Sub 1
Sub 2
Sub 3
Cat 2
Sub 1
Sub 2
Sub 3
Cat 3
Sub 1
Sub 2
Sub 3
Cat 4
Sub 1
Sub 2
Sub 3
...etc

?

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] Listing a categorys subcategories in home.htm In reply to
Hi,

Just....

Root
Cat 1
Cat 2
Cat 3
Cat 4
...etc

Cheers

Quote Reply
Re: [rootdk] Listing a categorys subcategories in home.htm In reply to
Try the following;

Code:
sub {

my $back;
my $cat_tbl = $DB->table('Category');
my $sth = $cat_tbl->select( { FatherID => '0' } ) || return $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . $cat_tbl->as_url($hit->{Full_Name});
$back .= Links::SiteHTML::display('subcategory_short', $hit);
}

return $back;

}

Call it with: <%your_global_name%>

You also need to create a new template, called subcategory_short. Put something like the below in it;

<a href="<%URL%>"><%Name%></a><BR>

Hope that helps :)

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!

Last edited by:

Andy: Dec 2, 2004, 4:16 AM
Quote Reply
Re: [Andy] Listing a categorys subcategories in home.htm In reply to
Hi,

Ok - thanks. Just one question more. I'm a newbie to Links SQL, so I need to know where to put the new sub-rutine.

Thanks
Quote Reply
Re: [rootdk] Listing a categorys subcategories in home.htm In reply to
No problem. You need to;

1) Click on Build > User Templates
2) At the bottom of this page, there is a blank TEXTAREA and TEXT field. Enter the global's name in the text field, and then the code in the TextArea. Then press the button.
3) Then, it should be accessable on pretty much any template (category.html, home.html, etc).

Hope that helps Smile

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] Listing a categorys subcategories in home.htm In reply to
Ok - got it.....

But now I get the error:


A fatal error has occured:
GT::SQL (73874): Unknown method 'as_url' called at (eval 33) line 6.


I'm really sorry to asked again, but I'm really lost here......
Quote Reply
Re: [rootdk] Listing a categorys subcategories in home.htm In reply to
No worries. Give the above version a go (I've modified it for you). I *think* the problem should be fixed up Smile

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] Listing a categorys subcategories in home.htm In reply to
Great Smile

I works fine. I have modified the code to:

sub {

my $back;
my $cat_tbl = $DB->table('Category');
my $sth = $cat_tbl->select( { FatherID => '1' } ) || return $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . '/' . $cat_tbl->as_url($hit->{Full_Name});
$back .= Links::SiteHTML::display('subcategory_short', $hit);
}

return $back;

}

This gives me what I want without an additional template.

Thanks a lot for your accurate and quick help :o)

Cheers
Quote Reply
Re: [rootdk] Listing a categorys subcategories in home.htm In reply to
Glad it works Smile

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] Listing a categorys subcategories in home.htm In reply to
How do you show?

Root
Cat 1
Sub 1
Sub 2
Sub 3
Cat 2
Sub 1
Sub 2
Sub 3
Cat 3
Sub 1
Sub 2
Sub 3
Cat 4
Sub 1
Sub 2
Sub 3
...etc


Can u help me? Please!!!!!!!!!!!!!!
Jason Bishop