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

How do I create a def file?

Quote Reply
How do I create a def file?
I added a new table to my db for an external mod I am writing. The mod really has nothing to do with links, I just want to be able to use links easy to use modules and includes. If I try and call the table using the usual methods, I get an error:

Quote:

GT::SQL (3646): File 'my_paths.../cgi-bin/admin/defs/Tricks.def' does not exist or the permissions are set incorrectly at trick.cgi line 38.


I added the table through mysqlman (or any other table editing software for whatever purposes). My point is, is there a way to add the table through links so that the def file is created automatically? I realize I could enter the information in a def file manually, or use regular mysql perl parsing tools, but I want to integrate it into links as much as possible with little difficulty...

Please help me help myself Angelic (whatever that smile is?!?)

Thanks,

- Jonathan

Last edited by:

jdgamble: Jan 27, 2005, 12:41 AM
Quote Reply
Re: [jdgamble] How do I create a def file? In reply to
Hi,

The best way to do this, is by creating a basic plugin. You need to create the table via the Install.pm file via $DB->creator(). To find out the exact format, it may be an idea to look at an existing plugin, and see how that is done.

Its pretty simple once you've done it before... but the first time is always a PITA =)

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How do I create a def file? In reply to
That makes sense...

Ok Thanks I'll give it a go...Cool

- Jonathan
Quote Reply
Re: [jdgamble] How do I create a def file? In reply to
I did find that once I create the table and the def file, it is easy to edit the def file by using:

http://yoursite.com/...mp;do=editor_columns

I will look into this stuff (hehe) more and post a reply once I have a question, and I will have a question...


Thanks again...

- Jonathan
Quote Reply
Re: [jdgamble] How do I create a def file? In reply to
In simple terms, I was able to create a simple field using the perl script, then edit the fields using the tools GT already has (I don't know why they don't have tools already create tables, drop, etc that mess with def files too)...

Anyway, here is the script I used...

Code:
#!/usr/bin/perl #================================ use strict;
use lib 'admin path';
use Links qw/$IN $CFG $DB/;
Links::init('admin path'); local $SIG{__DIE__} = \&Links::fatal;
main(); sub main {
#---------------------------------------------------
# my ($table_name, $creator); $table_name = "Tricks"; $creator = $DB->creator($table_name); # create a dummy column

$creator->cols(
TrickID => {
pos => 1,
type => 'INT',
size => '10',
not_null => 1,
default => 0
}
); # set the primary key $creator->pk('TrickID'); # will not work if table exists $creator->create(); print $IN->header();
print qq|<a href="$CFG->{admin_root_url}/admin.cgi?do=editor_columns&db=$table_name">Go to Editor</a>|;
}

I could have covered errors etc, but I decided just to post the simple code for anyone's reference...

- Jonathan
Quote Reply
Re: [jdgamble] How do I create a def file? In reply to
For creating def file

http://www.gossamer-threads.com/...orum.cgi?post=254807

See if that helps, though it deals with GM but the idea is there.

HyTC

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================