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

Add new table related to links

Quote Reply
Add new table related to links
Hi folks,

how can I add a new table with geographical and some more standard information related to existing/new link resources? I mean not to simple add a new table in an existing database ;-) I mean the build of a relation to the "Links"-Table.
I know, I can add a few more fields in the "Links"-table but in fact of redundancy, I try to find a solution with a new table... like "Links_geo_and_more_info".
The next problem is: Can I sort the links with a field of the related table? Can I force the internal search engine to find links depending on fields of the "Links_geo_and_more_info"-table? Does a simple template-modification (for example in add.html, link.html...) with the entry of the new fields still working? How to index and set up the relation between the new "Links_geo_and_more_info"-table and "Links"-table?

I know, a lot of questions, but I think a solution can be a concept-solution or a part of a FAQ for many other ideas.

kind regards


Last edited by:

Vavilis: May 3, 2005, 1:26 AM
Quote Reply
Re: [Vavilis] Add new table related to links In reply to
For the first part of your question, yes, you can add new tables and add relations. For this, you'll use GT::SQL::Editor and GT::SQL::Creator. Full documentation is available in the help section of the admin panel.

You'll do something like this:
use strict;
use GT::Base;
use Links qw/$DB/;

my $table = $DB->creator("Links_Info");

LinkID => { pos => 1, type => "INT", size => 11, not_null => 1 },
Example => { pos => 2, type => "VARCHAR", size => 255, not_null => 1}



$DB->editor("Links")->add_fk("Links_Info", { ID => "LinkID" });

I think you can sort on your foreign key relation. Under "build options", there's a section for sort orders. You may need to use "Links_Info.column_name" instead of just "column_name", but I'm not sure.

Searching I would assume would work fine. When you add foreign keys, records with matching fields between two tables get merged together when you run your queries. You might need to add a search weight property when you set up the table.

As per adding links, I'm not sure. You might need to use a hook to insert data into the new table. On the admin side, you'll need to use MySQLMan to manage your new table.

I hope that was a little helpful.

Limecat is not pleased.