Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Pagebuilder custom global error

Quote Reply
Pagebuilder custom global error
Hi Yogi,

I've turned up an odd error when using a couple of custom global with a 'Simple' pagebuilder page.

global1:

sub {
# -------------------------------------------------------------------
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $sth = $cat_db->select ( { FatherID => 0, ShowBrand => 'Yes'}, ['Full_Name','ID','Name'] );
my $output=qq~~;
my $i=0;
while (my ($root_cat,$ID,$heading) = $sth->fetchrow_array) {
$i++;
my $url1 = $cat_db->as_url($root_cat);
$output.= qq~<a href="$CFG->{build_root_url}/$url1/" class="internal">$heading</a><br />\n~;
$cat_db->select_options ('ORDER BY Full_Name');
}
return $output;
}

global2:

sub {
# -------------------------------------------------------------------
my $type = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $cond = GT::SQL::Condition->new( 'FatherID', '=', '0', 'CategoryType', '=', 'Brand', 'Number_of_Links', '>', '0');
my $sth = $cat_db->select ( $cond, ['Full_Name','ID','Name','Number_of_Links'] );
my $hits = $cat_db->hits;
my $breakpoint = int ($hits / 2) + (($hits % 2) ? 1 : 0);
my $output=qq~<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="top"><td width="50%">~;
my $i=0;
while (my ($root_cat,$ID,$heading,$total) = $sth->fetchrow_array) {
$i++;
my $url1 = $cat_db->as_url($root_cat);
$output.= qq~<p class="menu-right">$i: <a href="$CFG->{build_root_url}/$url1/">$heading</a></p>~;
$cat_db->select_options ('ORDER BY Full_Name');
if (!($i % $breakpoint)){$output.=qq~</td><td width="50%">~;}
}
$output.="</tr></table>";
return $output;
}


Both return the following error when used together or separately.

Quote:
A fatal error has occured:

Can't call method "fetchrow_array" on an undefined value at (eval 19) line 9.

Links (15832): Links::environment called at /home/virtual/site2/fst/var/www/cgi-bin/admin/Links.pm line 431 with no arguments.
Links (15832): Links::fatal called at (eval 19) line 9 with arguments
(Can't call method "fetchrow_array" on an undefined value at (eval 19) line 9.
).
Links (15832): Links::__ANON__ called at /home/virtual/site2/fst/var/www/cgi-bin/admin/GT/Template.pm line 843 with arguments
(HASH(0x85d17bc)).
Links (15832): GT::Template::_get_var called at /home/virtual/site2/fst/var/www/cgi-bin/admin/templates/pagebuilder/compiled/site_map.html.compiled line 42 with arguments
(GT::Template=HASH(0x85d1804), menu_brand_top10, 0, 1).
Links (15832): GT::Template::parsed_template called at /home/virtual/site2/fst/var/www/cgi-bin/admin/GT/Template.pm line 600 with arguments
(GT::Template=HASH(0x85d1804)).
Links (15832): GT::Template::_parse called at /home/virtual/site2/fst/var/www/cgi-bin/admin/GT/Template.pm line 101 with arguments
(GT::Template=HASH(0x85d1804), site_map.html, HASH(0x84ca73c)).
Links (15832): GT::Template::parse called at /home/virtual/site2/fst/var/www/cgi-bin/admin/Links.pm line 292 with arguments
(GT::Template, site_map.html, ARRAY(0x84f42f8), HASH(0x84ca73c)).
Links (15832): Links::user_page called at /home/virtual/site2/fst/var/www/cgi-bin/admin/Plugins/PageBuilder.pm line 725 with arguments
(site_map.html, HASH(0x8491f40), HASH(0x84ca73c)).
Links (15832): Plugins::PageBuilder::_build_simple_page called at /home/virtual/site2/fst/var/www/cgi-bin/admin/Plugins/PageBuilder.pm line 646 with arguments
(HASH(0x818b294)).
Links (15832): Plugins::PageBuilder::build_main called at nph-pagebuilder.cgi line 51 with no arguments.
Links (15832): main::_build_all called at nph-pagebuilder.cgi line 33 with no arguments.
Links (15832): main::main called at nph-pagebuilder.cgi line 25 with no arguments.


The page returning this error is setup like this:

<html>

<head>
<title><%title_unlinked%></title>
</head>

<body>

<h1><%page_title%></h1>

<p><%global1%></p>

<p><%global2%></p>

</body>
</html>

[EDIT]

Just noticed something that seems relivant - one of the pages that successfully builds before the page above uses this global:

sub {
# -------------------------------------------------------------------
my $type = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $cond = GT::SQL::Condition->new( 'FatherID', '=', '0', 'CategoryType', '=', 'Brand', 'Number_of_Links', '>', '0');
my $sth = $cat_db->select ( $cond, ['Full_Name','ID','Name','Number_of_Links'] );
my $output=qq~~;
my $i=0;
while (my ($root_cat,$ID,$heading,$total) = $sth->fetchrow_array) {
$i++;
my $url1 = $cat_db->as_url($root_cat);
$output.= qq~<p class="menu-brand-window">$i: <strong><a href="$CFG->{build_root_url}/$url1/">$heading</a> ($total)</strong></p>~;
$cat_db->select_options ('ORDER BY Full_Name');

}
return $output;
}

Will i need to change the names of the variables in the two globals (at the top of this post) ie. while (my ($root_cat,$ID,$heading) = $sth->fetchrow_array) {

Is it possable the variable names could be causing a conflict?

thanks,

Charlie Abbott



Comedy Quotes - Glinks 3.3.0, PageBuilder, StaticURLtr, CAPTCHA, User_Edit_Profile

Last edited by:

Chas-a: Feb 16, 2004, 5:08 PM
Subject Author Views Date
Thread Pagebuilder custom global error Chas-a 1967 Feb 16, 2004, 4:50 PM
Post Re: [Chas-a] Pagebuilder custom global error
Andy 1902 Feb 17, 2004, 12:29 AM