Gossamer Forum
Home : Products : Links 2.0 : Customization :

Help adding 2 extra fields in Links

(Page 1 of 2)
> >
Quote Reply
Help adding 2 extra fields in Links
Hi!

After reviewing several old posts, I tried to add a couple of new fields to the links database and the only think I got is to corrupt the database itself...

Is anyone so kind to help me?

I want to add the following two fields:

ICQ: 9999999999
PIC URL: http://xxx.xxxxx.xxx/xxxxxxxx/xxxxx/

So, a numeric field (say length 10, I dunno how many UINs ICQ can handle ;) and a second URL field.

Next, it would be great to reset ICQ field to '1' and URL field to a URL that would reflect a 'non-supplied image' image, this way people that does not have an image OR is not willing to update that URL field won't get a corrupted image when displaying the details on the database.

Finally, I don't know if anyone has managed to make the ICQ flower icon to display according to their online status (ie. if the person helding the link in my datbaase is ONLINE, the ICQ flower would be green, based on the ICQ UIN status).

Thanks SOOOOOOOOO much in advance!


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
After adding the fields in the %db_def hash in the links.def file, you need to UPDATE your links.db file using the upgrade.pl script posted in this forum...

And what you should do is add one field at time and then upgrade your database twice...once after you add the first field, the second after you add the second field.

OR edit your database file with an offline database program, like MS Access or Excel.

Don't know how to do that???

Search the forum for offline editing and don't forget to update your linksid.txt file.

Regards,

Eliot Lee
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi!

Thanks for the help..... It took me half an hour to find a working version of update.pl but it STILL does not work.

See, after modifying links.def, now I have:

Code:
Û_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '. @. \.. '],
Hits => [8, 'numer', 10, 10, 1, '0', '\d '],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.] $'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d $'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
DateAdded => [14, 'date', 15, 15, 0, \&get_date, ''],
ICQ => [15, 'numer', 10, 10, 0, '', '']
);
Then, I reflect the required information in the update.pl script I found:

Code:
#!/usr/bin/perl
# -------------------------------------------
#You must edit YOUR links.def script BEFORE entering these variable and running this script!
$field_default = "1"; #Put the default value of the new field here. Leave Blank for no default.
$new_field = "15"; #Put the new field number here.
$total_fields = "16"; #Put the last field number here.
#Change these value to match your settings
require "/usr/home/webcam/usr/local/etc/httpd/camcities.com/cgi-bin/admin/db_utils.pl";
require "/usr/home/webcam/usr/local/etc/httpd/camcities.com/cgi-bin/admin/category.def";

#You shouldn't have to edit below this line
#------------------------------------------
$nfm1 = $new_field - 1;

$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "<links.db") or print "Unable to open links database 'links.db'. Reason: $!" and exit;
print "\topening output file . . .\n";
open (DBOUT, ">links2.db") or print "Unable to open output database. Reason: $!" and exit;
print "\n\n\tProcessing records\n";
while (<DB> ) {
(/^#/) and next line; # Skip comment lines.
(/^\s*$/) and next line; # Skip blank lines.
chomp; # Remove trailing new line.
@rec_in = &split_decode($_);
# Copy ID, Title, URL, Date and Category
for $i (0 .. $nfm1) {
$rec_out[$i] = $rec_in[$i];
}
# Add New Field
$rec_out[$new_field] = "$field_default";
# Copy the rest of old links.db to new links2.db
for $i ($new_field .. $total_fields) {
$rec_out[$i 1] = $rec_in[$i];
}
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Database saved it as links2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'links2.db' to 'links.db before using with Links v2.\n";
print "It is recommend you save the original 'links.db' before renaming.\n\n";
Then execute the script.

Everything seems to work ok, but note the results:

ORIGINAL LINKS.DB entry:
Code:
4|WebCam World WebCams|http://...(snipped)...@hotmail.com|495|No|No|4.12|8|Yes|24-mar-99
MODIFIED LINKS2.DB (by update.pl)
Code:
4|WebCam World WebCams|http://...(snipped)...@hotmail.com~~495~~No~~No~~4.12~~8~~Yes~~24-mar-99
Not only update.pl failed to add the field but I got all those ~'s added to the end of the database...

Ideas?

Thanks!

Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Try using the absolute path to links.db and links2.db in upgrade.pl.

Thomas
http://www.japanreference.com
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi!

That made no difference....

Why would a path be implied on the error?

Both files were read and written correctly, so....

Anything else? ;)

Thanks!


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Like I said before...you need to add one field at a time and then execute the upgrade.pl. If you are trying to add both fields via the upgrade.pl, it will not work...the script works to update your links.db with one field added at a time.

I think your problem stems from not following the advice I gave above.

Regards,

Eliot Lee
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi!

I thank you as you try to help everyone, but you're the one that don't seem to read the threads ;)

If you notice the original question, I'm trying to add 2 new fields, ICQ and PIC URL. If you notice my message with the embeded code I used, ONLY the ICQ field is the NEW one being added, and the problems I'm experiencing are AFTER adding ICQ field (and ONLY ICQ field) to links.def and then run update.pl: a new file (links2.db) is correctly created (no problem on paths then), with the contents of the whole DB, but they're all messed up with that garbage at the end of the last 4 fields.

I still don't know where those ~'s are coming from and why the field is not being added at all.

If there are any more suggestions, I'll thank them all.

Thanks!

Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi!

Also, reading past posts, people has indeed succeeded in adding more than 1 and more than 2 fields into the Links database.

That latest chat about PERL sharks left you blind or something? ;)


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
In Reply To:
but you're the one that don't seem to read the threads

In Reply To:
That latest chat about PERL sharks left you blind or something? ;)
Good luck finding a solution on your own.


Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Like AnthoRukes said before...you need to add one field at a time and then execute the upgrade.pl.

Who's not reading post in this thread?


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Before I even started links I made new fields in the category.def file:
Code:
zone => [8, 'numer', 2, 2, 0, '', ''],
Then I added this to my site_html_templates.pl in sub_html_category:
Code:
zone => $zone,
When I try to use <%zone%> I get nothing. Any ideas where I forgot something?


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi christinz!

Is this some kind of joke?

Do I REALLY need to REPEAT I just added ONE FIELD and then run UPGRADE.PL?

If you were joking, I wasn't.

:(


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi Paul Wilson,

Why did you (intentionally?) forget to add the smiley AFTER my own sentence when quoting my words?

"but you're the one that don't seem to read the threads ;)"

I'm 500% sure you know the meaning of ";)" so I won't explain it... and I'm sure that if you read the whole thread, beginning from the first post I made until my last one, you'll notice who reads what or not...

Finally, if you're so pissed of a thread someone posted regarding his view on what these forums are about and who helps and who doesnt.... a reply like

"Good luck finding a solution on your own"

makes me think of one single thing:

Why are these forums still open? Why dont you just close them all? Why would we need support from someone that won't just help?

I've been reading posts from everyone in these forums since I got my own copy of Links, back in 1999... and I've enjoyed all the posts, as they've helped me out building my own site.. Do I really need to answer EVERY message in these forums so authors feel important?

As someone said "we're here helping out without expecting anything in exchange", so why is this changing NOW?

Oh well....


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
dprohit,

My original question goes your way, just notice that each time you add a new field, some sort of updater program must be run in order for the database to recognize the new field.

That's what I'm trying to clarify in this thread, but I never thought I'd get flamed this way...


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Webcamworld,
don't get me wrong now, I am not replying because I feel important, but just because of the fact I was recently updating my own database with two additional fields... Wink

As indicated in this very thread, you need to add all new fields to links.def, upload it, add the first field to your database with upgrade.pl, change the settings in upgrade.pl and run it again in order to add the second field. Worked fine for me.

Thomas
http://www.japanreference.com
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi thomas1,

Thanks for your kind answer ;)

As I see everyone is repeating the same thing over and over, I'll have to redo my question...

OK, let's assume I just want ONE FIELD AND ONLY ONE (did I said ONE loud enough? ;) to be added to the database... (hey! I only want ONE FIELD to be added! ;)

Wouldn't the steps (as outlined above) be:

1) open links.def
2) add the new field
3) close links.def (saving it!)
4) update information on the update.pl script
5) RUN update.pl script

IS THIS OK? Correct me if I'm wrong.

Please let me know.


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
100% correct. Step 3a would be uploading links.def. :)

Thomas
http://www.japanreference.com
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi again!

100% correct?

GRRRRRRRRRRRREEEEEEEEEAT!

Now guess the results when I do that! ;)

The same ones I posted above!

Know why? Coz I was already adding JUST ONE NEW FIELD (as I stated all the times) and everyone was replying with a why-the-hell-are-you-trying-to-add-TWO-fields-at-the-same-time answer... :)

Sooooooooooooo...

I end up with a "corrupted" database with no new field at all!

ORIGINAL LINKS.DB entry:
4|WebCam World WebCams|http://...(snipped)...@hotmail.com|495|No|No|4.12|8|Yes|24-mar-99

MODIFIED LINKS2.DB (by update.pl)
4|WebCam World WebCams|http://...(snipped)...@hotmail.com~~495~~No~~No~~4.12~~8~~Yes~~24-mar-99

Not only update.pl failed to add the field but I got all those ~'s added to the end of the database...

Ideas?

Thanks!

(let's see if we can keep the good path of this thread! ;)
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
If you want, send me your links.def and upgrade.pl files along with an example of your link.db, I'll have a look at it.

Thomas
http://www.japanreference.com
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Not sure how many files/records you have...but have you considered manually inputing the two ||'s in your database. If you don't have that many, just type them in or if you have too many you could use something like access to add two colums with a pipe. It sounds like the update script your using is corrupting your file one way or another.

Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Hi Domenic,

You mean:

1) to open current links.db
2) add two ||'s at the end of every record
3) then add new field to links.def
4) then running update.pl

?

Otherwise, please specify order.

THanks!


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
thomas1,

In case Domenic's solution fails, where do I send you those?

Thnks!


Quote Reply
Re: Help adding 2 extra fields in Links In reply to
No actually, once you add the two ||'s you will not need to use update.pl. So, just add the fields to the link.def file and then add the pipes and you should be set.

Quote Reply
Re: Help adding 2 extra fields in Links In reply to
To the email address in my profile pls.

Thomas
http://www.japanreference.com
Quote Reply
Re: Help adding 2 extra fields in Links In reply to
Domenic,

Ok then, this means I can add "|1|" and it will default the new field to 1?

And then if later I wanna add a URL type field, I just add (again) a "||" and that's all?

THanks!

> >