Hi all,
I'm having the damndest time trying to load up some information from a custom table I've made. The table is active and working and I've accessed it from various other functions in similar ways.
The table is a basic reference table similar to the CatLinks table. It has two columns LinkID and VerticalID (references a custom Vertical industry table.)
Anyway, I'm writing a plugin for the admin view so admins can seach and list all of Links by Vertical. Here's the basics of my Plugin:
# Plugins::search_verts - Auto Generated Program Module
#
# Plugins::search_verts
# Author : MP
# Version : 1
# Updated : Tue Mar 2 13:35:44 2004
#
# ==================================================================
#
package Plugins::search_verts;
# ==================================================================
use strict;
use GT::Base;
use vars qw/$VERSION $DEBUG $NAME $FONT/;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;
use GT::Dumper;
use GT::SQL;
require Links::Link;
# Inherit from base class for debug and error methods
@Plugins::search_verts::ISA = qw(GT::Base);
# Your code begins here! Good Luck!
# ADMIN MENU OPTIONS
# ===================================================================
sub print_form {
# -------------------------------------------------------------------
# This subroutine will get called whenever the user clicks
# on 'Search Verticals' in the admin menu. Remember, you need to print
# your own content-type headers; you should use
#
my $vert = "";
my $results = "what the fuck";
my $db = new GT::SQL '/var/www/clients.kbpwest.com/cisco/content_dev/admin/defs';
# Do something useful here
print $IN->header;
print Dumper(\@args);
# create the form element
my $output = Links::Link::HTML::disp_verticals_form();
# get the verts searched
my $vert_db = $DB->table ('Verticals');
my $vertlink_db = $DB->table('VertLinks');
my $linkdb = $DB->table ('Links');
if ($IN->param('VerticalID') != ""){
my @vert_ids = $IN->param('VerticalID');
foreach my $vert_id (@vert_ids) {
# locate the vertical name being searched
my @vert_names = $vert_db->select ( { ID => $vert_id } , ['Name'] )->fetchall_list;
foreach my $item(@vert_names){
$vert .= "You searched: $item\n";
}
# locate the links
my @links = $vertlink_db->select (['LinkID'], { VerticalID => $vert_id })->fetchall_list;
foreach my $link(@links){
# do something
my $results .= "link id found: $link\n";
}
}
return $results;
}
}
For some weird reason, NO MATTER WHAT I TRY, I just can't access the VertLinks table from the plugin. I've tried to feed the select function conditional statements, a plain number variable, and nothing works. I've also tried to call a similar Link ID list using the CatLinks table and no joy. Is there something I should know about accessing a reference table like this from a plugin? What's going on here?
Thanks,
Mike
I'm having the damndest time trying to load up some information from a custom table I've made. The table is active and working and I've accessed it from various other functions in similar ways.
The table is a basic reference table similar to the CatLinks table. It has two columns LinkID and VerticalID (references a custom Vertical industry table.)
Anyway, I'm writing a plugin for the admin view so admins can seach and list all of Links by Vertical. Here's the basics of my Plugin:
Code:
# ================================================================== # Plugins::search_verts - Auto Generated Program Module
#
# Plugins::search_verts
# Author : MP
# Version : 1
# Updated : Tue Mar 2 13:35:44 2004
#
# ==================================================================
#
package Plugins::search_verts;
# ==================================================================
use strict;
use GT::Base;
use vars qw/$VERSION $DEBUG $NAME $FONT/;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;
use GT::Dumper;
use GT::SQL;
require Links::Link;
# Inherit from base class for debug and error methods
@Plugins::search_verts::ISA = qw(GT::Base);
# Your code begins here! Good Luck!
# ADMIN MENU OPTIONS
# ===================================================================
sub print_form {
# -------------------------------------------------------------------
# This subroutine will get called whenever the user clicks
# on 'Search Verticals' in the admin menu. Remember, you need to print
# your own content-type headers; you should use
#
my $vert = "";
my $results = "what the fuck";
my $db = new GT::SQL '/var/www/clients.kbpwest.com/cisco/content_dev/admin/defs';
# Do something useful here
print $IN->header;
print Dumper(\@args);
# create the form element
my $output = Links::Link::HTML::disp_verticals_form();
# get the verts searched
my $vert_db = $DB->table ('Verticals');
my $vertlink_db = $DB->table('VertLinks');
my $linkdb = $DB->table ('Links');
if ($IN->param('VerticalID') != ""){
my @vert_ids = $IN->param('VerticalID');
foreach my $vert_id (@vert_ids) {
# locate the vertical name being searched
my @vert_names = $vert_db->select ( { ID => $vert_id } , ['Name'] )->fetchall_list;
foreach my $item(@vert_names){
$vert .= "You searched: $item\n";
}
# locate the links
my @links = $vertlink_db->select (['LinkID'], { VerticalID => $vert_id })->fetchall_list;
foreach my $link(@links){
# do something
my $results .= "link id found: $link\n";
}
}
return $results;
}
}
For some weird reason, NO MATTER WHAT I TRY, I just can't access the VertLinks table from the plugin. I've tried to feed the select function conditional statements, a plain number variable, and nothing works. I've also tried to call a similar Link ID list using the CatLinks table and no joy. Is there something I should know about accessing a reference table like this from a plugin? What's going on here?
Thanks,
Mike