Gossamer Forum
Home : Products : Gossamer Links : Discussions :

New Table + Globals

Quote Reply
New Table + Globals
Hi,

I have created a table called "Relations" in my Link SQL database & I would like to be able to show different fields from this Table using Globals!

So this is what I did:

1. First I created a table called "Relations" using MYSQLMAN then I created a .def file for this table!

2. I added a global called "related_news" here is the code:

Code:
sub related_news {
my $tags = shift;
my $related_db = $DB->table('Relations');
my $id = $tags->{ID};
my $related_news = $related_db->get($id, 'HASH');
return $related_news;
}

3. Then I added <%related_news%> into my templates and it gives me the following error:

Code:
Error: Unable to load module: Links::Options. Reason:
Can't locate Links/Options.pm in @INC (@INC contains: /home/virtual/mysite/home/httpd/CGIFiles/headlines/admin /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 .) at /home/virtual/mysite/home/httpd/CGIFiles/headlines/admin/GT/Template.pm line 657. ,
Error: No subroutine 'Links::Options::related_info' in 'Links.pm'
sub related_news { my $tags = shift; my $related_db = $DB->table('Relations'); my $id = $tags->{ID}; my $related_news = $related_db->get($id, 'HASH'); return $related_news; }

All I want to do is to be able to call 2 fields from this table ("ID" & "RelatedTitle"). I would really appreciate it if you can help me with this ASAP. I have been trying to fix this up for hours now but no luck Unsure

Thanks in advance,
PCMANIA
Quote Reply
Re: [pcmania] New Table + Globals In reply to
Hi,

Make sure you don't have anything for 'subclass' in your def file. Something is trying to load Links::Options (not a standard module, maybe look for where that is mentioned).

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] New Table + Globals In reply to
Hi Alex,

I don't have anything in front of my subclass here it is:

Code:
{
'ai' => 'ID',
'cols' => {
'NewsID' => {
'default' => '0',
'not_null' => '1',
'pos' => '1',
'type' => 'BIGINT',
'unsigned' => '0',
'zerofill' => '0'
},
'RelationID' => {
'default' => '0',
'not_null' => '1',
'pos' => '2',
'type' => 'BIGINT',
'unsigned' => '0',
'zerofill' => '0'
},
'NewsTitle' => {
'binary' => '0',
'default' => '',
'not_null' => '1',
'pos' => '3',
'size' => '255',
'type' => 'VARCHAR'
},
'ID' => {
'default' => '',
'not_null' => '1',
'pos' => '4',
'type' => 'BIGINT',
'unsigned' => '0',
'zerofill' => '0'
},
'RelationTitle' => {
'binary' => '0',
'default' => '',
'not_null' => '1',
'pos' => '5',
'size' => '255',
'type' => 'VARCHAR'
},
'Date' => {
'binary' => '0',
'default' => '',
'not_null' => '1',
'pos' => '6',
'size' => '11',
'type' => 'VARCHAR'
}
},
'fk' => {},
'fk_tables' => [],
'index' => {
'NewsID' => [
'NewsID'
]
},
'pk' => [
'ID'
],
'subclass' => {
'html' => {},
'table' => {}
},
'unique' => {}
};




Please take a close look at my Global Code cause I am a newbe and something might be wrong in there!

Thanks,

Pcmania

Last edited by:

pcmania: Jan 25, 2002, 1:52 PM
Quote Reply
Re: [pcmania] New Table + Globals In reply to
This:
Code:
'subclass' => {
'html' => {},
'table' => {}
},
Should be:
Code:
'subclass' => {},

Adrian
Quote Reply
Re: [brewt] New Table + Globals In reply to
Thanks Adrian,

Now it is giving me the Global Code as the output!!! Here it is:

Code:
sub related_news { my $tags = shift; my $related_db = $DB->table('Relations'); my $id = $tags->{ID}; my $related_news = $related_db->get($id, 'HASH'); return $related_news; }

What should I do now?

Thanks,
PCMANIA
Quote Reply
Re: [pcmania] New Table + Globals In reply to
Shouldn't that be:
Code:
sub {
my $tags = shift;
my $related_db = $DB->table("Relations");
my $id = $tags->{ID};
my $related_news = $related_db->get($id, "HASH");
return $related_news;
};
So that in globals.txt it looks like:
Code:
'related_news' => 'sub {
my $tags = shift;
my $related_db = $DB->table("Relations");
my $id = $tags->{ID};
my $related_news = $related_db->get($id, "HASH");
return $related_news;
};',

Adrian
Quote Reply
Re: [brewt] New Table + Globals In reply to
Hi Adrian,

I changed that to

Code:
sub { my $tags = shift; my $related_db = $DB->table("Relations"); my $id = $tags->{ID}; my $related_news = $related_db->get($id, "HASH"); return $related_news; };

However when I try to build my pages it is giving me the following error:

Code:
A fatal error has occured:GT::SQL::Table (19319): Configuration file '/home/virtual/mysite/home/httpd/CGIFiles/headlines/admin/defs/Relations.def' has been corrupted. Reason: Unmatched right bracket at /home/virtual/mysite/home/httpd/CGIFiles/headlines/admin/defs/Relations.def line 68, at end of line
syntax error at /home/virtual/mysite/home/httpd/CGIFiles/headlines/admin/defs/Relations.def line 68, near "}"
at /home/virtual/mysite/home/httpd/CGIFiles/headlines/admin/GT/SQL/Base.pm line 38.
Please enable debugging in setup for more details.

I switched back my Relations.def file's line 68 from:

Code:
'subclass' => {},

to

Code:
'subclass' => {

and it builds the pages and it gives me no error however it doesn't show any data for <%related_news%> tag in my templates! It is just blank!

Is the above code suppose to show me the ID field on my templates or is it suppose to show another field? If it is suppose to show the ID then how can I show another field? for example how can I show RelatedNews field?


Thanks again,
PCMANIA
Quote Reply
Re: [pcmania] New Table + Globals In reply to
Hello everyone,

I can really use some help here!

Thanks,
PCMANIA
Quote Reply
Re: [pcmania] New Table + Globals In reply to
Hello All,

While I was doing the above I tried to build my pages and Now I keep getting this Error message:

Code:
Building Detailed pages ...
A fatal error has occured:GT::SQL::Table (24415): Wrong argument passed to this subroutine. Usage: Must pass category id to template_set at (eval 39) line 7.
Please enable debugging in setup for more details.
Stack Trace
======================================
Links (24415): Links::environment called at /home/virtual/irankhabar/home/httpd/CGIFiles/headlines/admin/Links.pm line 418 with no arguments.
Links (24415): Links::fatal called at (eval 37) line 82 with arguments
(GT::SQL::Table (24415): Wrong argument passed to this subroutine. Usage: Must pass category id to template_set at (eval 39) line 7.
).
Links (24415): GT::Base::error called at /home/virtual/irankhabar/home/httpd/CGIFiles/headlines/admin/Links/Category.pm line 307 with arguments
(Links::Category=HASH(0x855a24c), BADARGS, FATAL, Must pass category id to template_set).
Links (24415): Links::Category::template_set called at (eval 35) line 57 with arguments
(Links::Category=HASH(0x855a24c), [undef]).
Links (24415): Links::Build::build_detailed called at /home/virtual/irankhabar/home/httpd/CGIFiles/headlines/admin/GT/Plugins.pm line 88 with arguments
(HASH(0x8601cb0)).
Links (24415): GT::Plugins::dispatch called at /home/virtual/irankhabar/home/httpd/CGIFiles/headlines/admin/Links/Build.pm line 30 with arguments
(GT::Plugins, /home/virtual/irankhabar/home/httpd/CGIFiles/headlines/admin/Plugins, build_detailed, *Links::Build::build_detailed, HASH(0x8601cb0)).
Links (24415): Links::Build::build called at nph-build.cgi line 523 with arguments
(detailed, HASH(0x8601cb0)).
Links (24415): main::_build_detailed called at /home/virtual/irankhabar/home/httpd/CGIFiles/headlines/admin/GT/Plugins.pm line 88 with arguments
(HASH(0x828bcf4)).
Links (24415): GT::Plugins::dispatch called at nph-build.cgi line 88 with arguments
(GT::Plugins, /home/virtual/irankhabar/home/httpd/CGIFiles/headlines/admin/Plugins, create_detailed, CODE(0x8263ce8), HASH(0x828bcf4)).
Links (24415): main::build_all called at nph-build.cgi line 43 with no arguments.
Links (24415): main::main called at nph-build.cgi line 30 with no arguments.

I see some HASH stuff in this error, what is that all about? I even deleted the whole Global but it is still giving me this error!

Please help me ASAP!

Thanks,
PCMANIA
Quote Reply
Re: [brewt] New Table + Globals In reply to
Hello,
Is it possible to make this code works from the admin side?
Means, I want to use diferent field from the new table to show out in the Add Form from the admin (Add > Link).
and the field that should show up in the Link Add Form should be treated like any other field in the form (can be searched for, read-only when viewing, pull always the right Field for the Right link id....etc.)

thank you for your help..
Mark