Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Tag Problem

Quote Reply
Tag Problem
Sorry, I have been searching the forum for 60 min now but I couldn't find any answer.

I am a beginner with GL so be patient with me, please Smile

How can I use this code from home.html in the category.html or any other template? I tried to copy the code in the category.html but it didn't work.

<%set split = Links::Utils::column_split($category_loop.length, $home_category_cols)~%><%loop category_loop%>
<%~set splitmod = $row_num % $split%>
<%~if row_num == 1 or splitmod == 1 or split == 1%><dl><%endif%>
<%~include subcategory.html%>
<%~if row_num == $category_loop.length or splitmod == 0%></dl><%endif%>
<%~endloop%>

I hope somebody can help me. Thanks in advance.

Steelhammer

Sorry for my English but I am not a native speaker Unsure
Quote Reply
Re: [Steelhammer] Tag Problem In reply to
Hi,

Why do you want to do that? Unsure

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] Tag Problem In reply to
Andy wrote:
Hi,

Why do you want to do that? Unsure

I want to show the main categories of the index/home.html on the category pages as well.

But I can't use any tag of the home.html in the category.html

How can I solve this problem?
Quote Reply
Re: [Steelhammer] Tag Problem In reply to
Hi,

So you want to show all the normal categories on category.html - and then below, have a list of your "root" categories too on category.html ?

You could use this global to do that:

Call it: get_home_cats - with this code:

Code:
sub {

my $tbl = $DB->table('Category');
$tbl->select_options ('ORDER BY Name DESC');
my $sth = $DB->select( { FatherID => 0 }) || die $GT::SQL::error;

my @loop;
while (my $row = $sth->fetchrow_hashref) {
$row->{URL} = $CFG->{build_root_url} . "/" . $row->{Name} . "/index.html";
push @loop, $row;
}

return { home_category_loop => \@loop }

}

Then call it with:

Code:
<%get_home_cats%>
<ul>
<%loop home_category_loop%>
<li><a href="<%URL%>"><%Name%></a><li>
<%endloop%>
</ul>

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: Jan 18, 2008, 12:58 AM
Quote Reply
Re: [Andy] Tag Problem In reply to
Andy wrote:
Hi,

So you want to show all the normal categories on category.html - and then below, have a list of your "root" categories too on category.html ?

You could use this global to do that:
...

Hi Andy,

thanks for your help but I got an error message:

Unable to compile 'get_home_cats': Global symbol "$db" requires explicit package name at (eval 33) line 5.

What does that mean?
Quote Reply
Re: [Steelhammer] Tag Problem In reply to
Hi,

Sorry, please try the modified version.

I had:

$db->table

..instead of:

$tbl->table

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] Tag Problem In reply to
Andy wrote:
Hi,

Sorry, please try the modified version.

I had:

$db->table

..instead of:

$tbl->table

Sorry Andy but that doesn't work.

I tried:

sub {

my $tbl = $tbl->table('Category');
$tbl->select_options ('ORDER BY Name DESC');
my $sth = $db->select( { FatherID => 0 }) || die $GT::SQL::error;

my @loop;
while (my $row = $sth->fetchrow_hashref) {
$row->{URL} = $CFG->{build_root_url} . "/" . $row->{Name} . "/index.html";
push @loop, $row;
}

return { home_category_loop => \@loop }

}

I got an error message:

Unable to compile 'get_home_cats': Global symbol "$tbl" requires explicit package name at (eval 33) line 3. Global symbol "$db" requires explicit package name at (eval 33) line 5.
Quote Reply
Re: [Steelhammer] Tag Problem In reply to
Code:
my $tbl = $DB->table('Category');
$tbl->select_options ('ORDER BY Name DESC');
my $sth = $tbl->select( { FatherID => 0 }) || die $GT::SQL::error;
Quote Reply
Re: [Steelhammer] Tag Problem In reply to
Hi,

Wychwood has it right =) You are editing too much of the code =) Only the lowercase $db, not $DB 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: [Wychwood] Tag Problem In reply to
Wychwood wrote:
Code:

my $tbl = $DB->table('Category');
$tbl->select_options ('ORDER BY Name DESC');
my $sth = $tbl->select( { FatherID => 0 }) || die $GT::SQL::error;

Wow, that's it. Many thanks for your patience and help.

May I ask one question more? Smile

Is it possible to show the number of links in each category as well? That would be nice ...
Now it only shows me the root categories without the number of links in each category.
Quote Reply
Re: [Steelhammer] Tag Problem In reply to
Hi,

Sure.

Just use:

Code:
<%get_home_cats%>
<ul>
<%loop home_category_loop%>
<li><a href="<%URL%>"><%Name%></a> (<%Number_of_Links%>)<li>
<%endloop%>
</ul>

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] Tag Problem In reply to
Andy wrote:
Hi,
Sure.

Just use:

...

Wow that's great. Again many many thanks to all.

Smile