Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Alternate Categories

Quote Reply
Alternate Categories
Does anyone know how to incorporate an alternate category field for the add.html or modify.html so that it is added to the Validation.db?

Also, how can one add more tables? Can the SQL.mysql file be edited and just add a def file, like all the other tables?

Thanks
Quote Reply
Re: Alternate Categories In reply to
It's really easy to add tables. I think you can do it in the Links Admin, if not, you can do it at the mysql prompt -- or if your server runs PHP you can install the phpMyAdmin program, and it becomes trivial.

Actually, Alex has the guts of the routines to allow you to define a table, then add it through the setup.cgi That might be a quick and dirty mod -- changing the setup.cgi to allow addition of tables as well as drop/create the whole database.

I don't use PHP on my server, but I have compiled it into Apache so _I_ can use a lot of features, and I might even make a PHP enabled bbs available. It does make coding for mySQL easier in some respects, but it's a server-side scripted language and as such, has more 'state' issues than Perl or Java. It is written to work closely to MySQL, so it does have that major advantage... and a lot of people are playing with it since it doesn't require cgi access or understanding Unix to work with it --- it's sort of like a Visual Basic in a Perl world.

As for the alternate categories.... I'm not clear on how they work. I have a feeling that when a more robust solution to the extensive category lists and having to enter category names as /name/name/name appears, it will cascade over to the alternate categories as well.

If you can't figure out how to add a new table, I'll write up some documentation, since for most of us it's second nature already Smile It's actually a lot esier than it seems, and it makes adding features really easy once you get the hang of it.

Each table can hold a collection of data, and you can relate it to other tables through common fields, which can then be 'joined'

In trying to attach things to the LinkID of Links Table, you need to add a field "LinkID" just like on the validation table, and store it. If you add an auto-inrement field as the first field of your table, you will always have a unique identifier. Most things in LinkSQL are related through the LinkID, which is the auto-increment field of the Links table.

The nice thing about SQL is that adding tables (files) means literally that -- just adding them. You don't have to deal with any of the code to manage them -- that's all part of the SQL engine, and all the higher-level featurew of LinkSQL are available too.




Quote Reply
Re: Alternate Categories In reply to
Hello!

Quote:
Also, how can one add more tables?

With less than one click with phpMyAdmin from www.phpwizard.net

Go in the browse function of that table. Below you will find

Copy table structure

with data or with out data.

What I did was configured Validate table final database design. I then also had Validate def.

Then I used phpMyAdmin and copied the structure into many, back_up, Links, imports,,,...

To apply the Validate def to other tables, I simply copied this defs and changed the top config area of those defs, for e.g. where ever the table name appeared change to the new one, change the ID or db_key if necessary, etc. Within minites you have exactly the same configuration of every thing possible that will not have any internal database conflicts at all.

This became absolutely necessary to have it done this way when using imports and they all should be compatible in every way.
Quote Reply
Re: Alternate Categories In reply to
Thanks guys. phpmyadmin looks great. I've read up and know how to create tables but I guess I was wanting to do what rajani did.

Rajani, could you give me an example. If I wanted to make a new table, can I just edit the code

$Links = qq~

CREATE TABLE Links (
ID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Title CHAR(100) NOT NULL DEFAULT 0,
URL CHAR(150) NOT NULL DEFAULT 0,

to something like

$Newtable -= qq~

CREATE TABLE Newtable (
ID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Newfield1 CHAR(100) NOT NULL DEFAULT 0,
Newfield2 CHAR(150) NOT NULL DEFAULT 0,

etc...

Then the same thing for the validate table

Is that how you did it?

Thanks for your help.

Kevin
Quote Reply
Re: Alternate Categories In reply to
IF you are willing to recreate your whole database, edit the SQL.mysql file, and change the database records to look like what you want them to look like, then run the setup.cgi program, and erase/create the tables.

You can just create the tables and you'll get a lot of errors on the tables that exist, but it won't do any damage -- the files in the def directory _will_ be overwritten though, so make a back up just in case you find you needed them the way they were (if you've changed a lot of defaults, etc.

Quote Reply
Re: Alternate Categories In reply to
about the alternate category in add.html

from what i know.. you can't do it with the add.cgi with regular code.. in links 2.0 it saved the data seperated by "~~" but using "CGI".. (use CGI () Wink $in->param('field'); of a field that has more than one value (checkboxes, multiple selects.. or just multiple fields with same name) the value will equal the last field..

i am going to do something similiar.. except have categories based on cpu and hardware.. i'm just going to hardcode things in..

1. they select subcategory..

ie. Games/Arcade Style

2. then they select the CPU types (yes/no fields for each cpu)..

ie. MIPS (Yes), SH3 (Yes), SH4 (No)

3. then the perl puts them into the categories..

Software/MIPS/Games/Arcade Style

etc..

(the first one being the main.. then rest alternates..)

jerry
Quote Reply
Re: Alternate Categories In reply to
i meant that CGI makes multiple selections the first value.. not the last Wink

something like this..

Code:
@vars = split /&/ $ARGV[0];
foreach (@vars) {
($name, $value) = split /=/, $_;
$in{$name} ? next : $in{$name} = $value;
}

so you can get an idea..

i'm not sure though if there is javascript so you can change the value of a multiple select field.. possibly.. otherwise you can just use plain old PERL and parse it..

it'd be like the above code except..

Code:
$in{name} ? ($in{$name} .= "~~$value") : ($in{$name} = $value);
jerry
Quote Reply
Re: Alternate Categories In reply to
Hi Kevin!

There are many possibilities to create new tables. Telnet SQL Monitor is one, Editor SQL Monitor is second and duplicating is the third. All does the same thing after all!

The reason why I ended doing things to duplicate is because of my nightmares during imports. To hunt for things and think where could be a problem took me a lot of time and as I am a novice in Perl and MySQL I had too much of troubles. I am convinced that all in a similar situation will have the same problems to go through. It is only therefore I came up with conclusions as such suggested.

During imports I had many many surprises. If the sequence of the fields are correctly numbered and the MySQL + phpMyAdmin is also showing the listing in "the same sequence", I could not import! Beleive me. I simply erased the table and re-created it again and everything worked fine. Defs were the same as well. In the earlier table i had once tried to change the index from one to the other and back to it again. That was the only difference. So you see, MySQL is very very fussy about tables in all form.

This was the main reason why I ended up in duplicating EXACTLY EVERYTHING THE SAME by simply copying them and I had less problems. It was easier for me to edit the defs and change the appropriate values to their respective tables rather than get into different indexes for Validates and different for Links etc. When something is different, I had problems during imports.

However you can achieve the same results with the help of Editor.cgi SQL Monitor.

What you asked is also the right way to do it (Pay attention there is a syntax error of the Variable $NewTable and thereafter is a dash, which should not be there, seems a typo). However what I did is to create the Validate table first "Considering all the necessary factors and the values of Links Table". I had all the indexes, field names compatible, etc. I made several tests on them to check if they were working fine and also the defs were fine. I then simply made duplicates of it within the database, for e.g. Links, Imports, Links_backup, Validate_backup, etc. The other tables that I do not use can simply remain hanging and it does not worry me. But they are there and correctly configured and ready to use anytime. To point to those tables you ofcourse need the related configured defs.

In this way, if it was working for Validate, it also worked for Links. The day I followed this system I had less problems. Earlier something was working for one and not for the other!

From experience : A freshly created table in exactly the same way how it should look like finally will give the best results and less problems. For this, phpMyAdmin was a good utility to use as you can simply export the structure configuration as a webpage, drop the table, create it through SQL Monitor of editor.cgi again. And you need to correct the defs again.

Mind you, at that time when I tried all this SQL.MySQL was not yet distributed. It is only now that Alex has been working on this brilliant web-interface. Also some of the experience I had some one could disagree. This is just to share my experience.