Hi,
I use the following plugin to customize the display of a link depending on what category it is in. Since upgrading to 2.2, I am having trouble reading the passed variables at the template. This plug in worked fine before the upgrade. Weird.
# ==================================================================
# Plugins::Link_Display - Auto Generated Program Module
#
# Plugins::Display_Link
# Author : MP
# Version : 1
# Updated : Fri Apr 9 12:57:47 2004
#
# ==================================================================
#
package Plugins::Display_Link;
# ==================================================================
use strict;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;
use GT::Dumper;
# Inherit from base class for debug and error methods
@Plugins::Display_Link::ISA = qw(GT::Base);
# Your code begins here! Good Luck!
# PLUGIN HOOKS
# ===================================================================
sub site_html_link {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'site_html_link'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#
my (@args) = @_;
# Do something useful here
my $cat_db = $DB->table ('Category')|| die $GT::SQL::error;
my $catlink_db = $DB->table('CatLinks')|| die $GT::SQL::error;
my $p = (ref $_[0] eq 'HASH') ? shift : {@_};
my $linkID = $p->{'ID'};
# get the catID for the current link
my $catID = $catlink_db->select ( { LinkID => $linkID } , ['CategoryID'] )->fetchrow;
my $linkType = $cat_db->select ( { ID => $catID } , ['Template'] )->fetchrow;
# add link new vars to @args
$args[0]{linkType} = $linkType;
# put carriage returns into the description
# $args[0]{'Description'} =~ s/\r?\n/<br>/g;
print Dumper(\@args);
return @args;
}
# Always end with a 1.
1;
The weird thing is that I can see the linkType variable in the args dump at the top of the page, but it doesn't make it through to the template itself.
I'm stumped. Anybody have any ideas?
Thanks,
Mike
I use the following plugin to customize the display of a link depending on what category it is in. Since upgrading to 2.2, I am having trouble reading the passed variables at the template. This plug in worked fine before the upgrade. Weird.
Code:
# ==================================================================
# Plugins::Link_Display - Auto Generated Program Module
#
# Plugins::Display_Link
# Author : MP
# Version : 1
# Updated : Fri Apr 9 12:57:47 2004
#
# ==================================================================
#
package Plugins::Display_Link;
# ==================================================================
use strict;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;
use GT::Dumper;
# Inherit from base class for debug and error methods
@Plugins::Display_Link::ISA = qw(GT::Base);
# Your code begins here! Good Luck!
# PLUGIN HOOKS
# ===================================================================
sub site_html_link {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'site_html_link'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#
my (@args) = @_;
# Do something useful here
my $cat_db = $DB->table ('Category')|| die $GT::SQL::error;
my $catlink_db = $DB->table('CatLinks')|| die $GT::SQL::error;
my $p = (ref $_[0] eq 'HASH') ? shift : {@_};
my $linkID = $p->{'ID'};
# get the catID for the current link
my $catID = $catlink_db->select ( { LinkID => $linkID } , ['CategoryID'] )->fetchrow;
my $linkType = $cat_db->select ( { ID => $catID } , ['Template'] )->fetchrow;
# add link new vars to @args
$args[0]{linkType} = $linkType;
# put carriage returns into the description
# $args[0]{'Description'} =~ s/\r?\n/<br>/g;
print Dumper(\@args);
return @args;
}
# Always end with a 1.
1;
The weird thing is that I can see the linkType variable in the args dump at the top of the page, but it doesn't make it through to the template itself.
I'm stumped. Anybody have any ideas?
Thanks,
Mike