Gossamer Forum
Home : Products : Links 2.0 : Customization :

Extra Fields

(Page 1 of 2)
> >
Quote Reply
Extra Fields
I would like to add a field to the add.cgi page that has a spot for someone to list the page that they link back to and for it to show up in the validation part of the admin panel. Suggestions on a step by step process?
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Look at "links.def"... near the top there's the definitions for the database structure. Any changes there are reflected in "add.cgi"
Quote Reply
Re: [Konichi] Extra Fields In reply to
Changes in links.def do not automaticaly show up in the add page, just in the admin. You would need to add the field to the add form, also to the modify form. Just look at a field that's already there, for instance the url field, since you want an url to a linked page, and copy that info. Also note that any change in the number of fields will require adding a new field space to all the links in the link.db, using a pipe |.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
Just wanted to see if you can help me do it? I am just wanting to create a field where they can list the url of the page they linked back to my site on. I don't know how.
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
I'll try, I may miss something...

In links.def, add this:

Recip => [14, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp']

after this:

ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],

be sure to add the comma!

Then add this:

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_recip = 14;

---
Next, in site_html_templates.pl, add this at the top of the file, in the globals:

css => $build_css_url,
recip => $recip,
banner => ''

(Actually, may not need this step; skip it unless you get an error saying 'unrecognized tag...')

---

Next, in your add template, add something like so:

<tr><td align="right" valign="top">Reciprical URL:</td>
<td><input name="Recip" size="50"></td></tr>

then in add_error:

<tr><td align="right" valign="top">Reciprical URL:</td>
<td><input name="Recip" value="<%URL%>" size="50"></td></tr>

then in add_success:

Reciprocal URL: <%Recip%>

And the same for the three modify templates.

---

In add.cgi, add this to sub send_email:

Title: $in{'Title'}
URL: $in{'URL'}
Reciprical URL: $in{'Recip'},
Category: $in{'Category'}
Description: $in{'Description'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}

Similar change to make in modify.cgi.

---

The hardest part is adding the new field to all existing links (unless this a new install, in which case there's nothing to worry about). This is made much easier using the script here:

http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=27938#27938

http://www.gossamer-threads.com/...cgi?post=48377#48377

---

After writing all this, while looking in my files for something else, I found this link:
http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=31234#31234


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
Ok I did all of this I'll try, I may miss something...

In links.def, add this:

Recip => [14, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp']

after this:

ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],

be sure to add the comma!

Then add this:

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_recip = 14;

---
Next, in site_html_templates.pl, add this at the top of the file, in the globals:

css => $build_css_url,
recip => $recip,
banner => ''

(Actually, may not need this step; skip it unless you get an error saying 'unrecognized tag...')

---

Next, in your add template, add something like so:

<tr><td align="right" valign="top">Reciprical URL:</td>
<td><input name="Recip" size="50"></td></tr>

then in add_error:

<tr><td align="right" valign="top">Reciprical URL:</td>
<td><input name="Recip" value="<%URL%>" size="50"></td></tr>

then in add_success:

Reciprocal URL: <%Recip%>

And the same for the three modify templates.

---

In add.cgi, add this to sub send_email:

Title: $in{'Title'}
URL: $in{'URL'}
Reciprical URL: $in{'Recip'},
Category: $in{'Category'}
Description: $in{'Description'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}

Similar change to make in modify.cgi.

and I get an error message saying

Error Message : fatal error: syntax error at /home/ldstryfe/public_html/cgi-bin/admin/links.def line 37, near "'http://' '^http|news|mailto|ftp'"
syntax error at /home/ldstryfe/public_html/cgi-bin/admin/links.def line 62, near "$db_sort_links "
Compilation failed in require at admin.cgi line 55.

Script Location : admin.cgi
Perl Version : 5.008001
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Did you put in the comma (for ReceiveMail)?

In links.def:


ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],

Recip => [14, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp']

Also, you can change the 1 to a 0 and the field will not be required. The 1 makes it required.

If that doesn't fix it, you may need to go into links.cfg, at the bottom of the file, and add this line to the Extra Paths:

$db_lib_path = $db_script_path; # PATH of library files.
$db_links_name = "$db_script_path/data/links.db"; # PATH to links database.
$db_recip = "$db_script_path/data/recip.db"; # PATH to reciprical link database.

And then create an empty file in the data directory named recip.db

And I noticed this error in my code above:

Quote:
then in add_error:

<tr><td align="right" valign="top">Reciprical URL:</td>
<td><input name="Recip" value="<%URL%>" size="50"></td></tr>


Should be:

<tr><td align="right" valign="top">Reciprical URL:</td>
<td><input name="recip" value="<%recip%>" size="50"></td></tr>

Actually, ALL instances of Recip need to be all lowercase: recip, except for the one in links.def, Recip => [14, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp']

And, if you have added any other mods that added fields to the links.def, then of course you need to adjust the field number accordingly, in both places in links.def. It is not important that it be number 14, just add it to the end of the list and number it in sequence.


Leonard
aka PerlFlunkie
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Error Message : fatal error: syntax error at /home/ldstryfe/public_html/cgi-bin/admin/links.def line 62, near "$db_sort_links "
Compilation failed in require at admin.cgi line 55.
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
I just put this in a test site I have, and it works fine. Recheck your codes, make sure there is a comma at the end of field 13.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
This is my def file. I have the commas but I don't understand why it doesn't work. I mean if you look at the error and where it's coming from it just looks strange.
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Hi. Looks like its down to;

Code:
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],

I guess it should be something like;

Code:
Rating => [11, 'numer', 10, 10, 1, 0, '^\d+\.\d\d$',

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: [LordStryfe] Extra Fields In reply to
In the part that says "Field numbers of some important fields" you need to add the semicolon:

$db_recip=14;


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
Found another problem. I am testing it now.

Last edited by:

LordStryfe: Jul 22, 2004, 6:35 PM
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Now when I try to add any links I get this message when adding them:
Error: Unable to Add Link

There were problems with the following fields:
  • Rating (Invalid format)

Please fix any errors and submit the record again.

But the number I have down is 0

Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Did you add a new field delimeter | to all your entries in links.db? Adding a field without to the links.def without adding it to the db will throw everything off.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
My links.db has | at the even of every entry where my recip link will be
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
It should have this info:

ID|Title|URL|Date|Category|Description|Contact Name|Contact Email|Hits|isNew|isPopular|Rating|Votes|ReceiveMail|Recip

or,

0|1|2|3|4|5|6|7|8|9|10|11|12|13|14

The last field (recip) can be empty, in which case you would have:

ID|Title|URL|Date|Category|Description|Contact Name|Contact Email|Hits|isNew|isPopular|Rating|Votes|ReceiveMail|

(I used the field name, not what would be in the db file.)
You may want to post the first few (3-4) entries from you link.db, then we can see what's going on.


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Jul 22, 2004, 10:01 PM
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
1|Christian window stickers, license plates, tire covers and t-shirts|http://www.goodnewsgraphics.com|13-Nov-2003|Shopping/Christian_Gift_Shops|Awesome Christian window stickers, license plates, t-shirts and spare tire covers. More than 95 designs...your choice of colors and sizes!!! ``FREE 3-pack of "Assorted Fish" window stickers with your order!``"witness without speaking a word"|Ernie Johns|goodnews@goodnewsgraphics.com|56|No|No|0|0|Yes|
2|Sound Doctrine Ministries|http://sounddoctrine.org/|25-Jul-2003|Ministries|Order free items. Devoted to discipleship issues. Home of the book, "Hating For Jesus" (John 12:25 & Luke 14:25-35)|Tim Williams|twilliams@saintmail.net|1|No|No|0|0|Yes|
3|Sarah Laughing - Independent Christian music funk and groove band|http://www.sarahlaughing.com|1-Jan-2004|Music/Bands_and_Artists/Indie_Music|Sarah Laughing - Independent Christian music funk and groove band. Click here|L Hartman|sarahlaughing@earthlink.net|1|No|No|0|0|Yes|
4|Community Church|http://www.info.bw/~commchch/|23-Mar-2003|Churches/Africa/Botswana|Francistown. Cell based charismatic church.|Senior Pastors John & Angela Bacon|commchch@info.bw|9|No|No|0|0|Yes|
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Well, those look OK... Did you use the script linked above to add the delimeters? Check your last few entries in the links.db, make sure they don't have an extra delimeter | in them. Or just use the admin to view the last link you added (Links/View), and see if all the data is in the right fields.


Leonard
aka PerlFlunkie
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Ok I checked the links.db and all of the fields are correct and to even test a theory I emptied out the links.db file, of course after making a copy, and it still didn't work blank.
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
ok I got it working
Quote Reply
Re: [LordStryfe] Extra Fields In reply to
Great! Smile What was the problem? Let us know what you did.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
Where the hell do I find "links.def" :)

cheers
Quote Reply
Re: [ukseo] Extra Fields In reply to
It's part of the Links2 download, and is used to define what the various fields mean. If you don't have it, you must have accidently deleted it.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Extra Fields In reply to
Ok I accidentally deleted my add page so I added in all of the fields but when I add the recip info, Mozilla states :Unknown Tag: Recip: suggestions?
> >