Gossamer Forum
Home : Products : Links 2.0 : Customization :

new field in add resource screen

Quote Reply
new field in add resource screen
Hi, Im fairly new to this and am trying to add a new yes/no field into the add a resource screen which will allow the submitter to state whether the site is UK based or not (isUK), Ive found a couple of references to this in the forums but they werent fully explained. Can anyone please give me a run through of how I can do this please?



thanks, grant
Quote Reply
Re: [grantw] new field in add resource screen In reply to
Try searching this forum for links.def add field.

Basically, it requires editing links.def, and the add_*.html templates.

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: [grantw] new field in add resource screen In reply to
Basically, just copy one of the existing fields that is like the one you want to create, add a comma to the last line of the db_def section, paste the new field after the last line of the existing db_def section. The last field definition should not have a comma at the end of it. Change the new field as needed. Download the links.db file and add the delimiter | to the end of each record. Or search the forum for a perl program to do it or use the csvdb program at http://home.hccnet.nl/s.j.francke/software/software.htm. Change the name of the links.db file on your server ( this will be your back up copy - you might even want to create a second backup by copying to another place on your server or local computer ). Upload the new links.def and links.db and set the correct permissions if needed.

in the db_def section of the links.def file, change

Code:
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']


to

Code:
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
isUK => [14, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] new field in add resource screen In reply to
Hi, thanks for the reply. I've done this and also added the new field here :

Code:
# 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_user = 14; $db_pw = 15; $db_isbest=16;
$db_isuk=17;



and here :



# Hash of column names to possible options. If you want to use a select form
# field, you can use &build_select_field in your HTML page. This routine will
# make a <SELECT> input tag using the following values:
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
ReceiveMail => 'Yes,No',
isBest => 'Yes,No',
isuk => 'Yes,No'

);


My problem is now getting the field to appear in the add resource pages and modify pages?

thanks, grant
Quote Reply
Re: [grantw] new field in add resource screen In reply to
Outstanding! You've got the hang of it.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] new field in add resource screen In reply to
Ok, ive managed to get all this working, the last thing I want to do is. if isUK = true it will have an icon next to it in the listings. I have put this into link.html

Code:
<%if isUK%>
<img src="<%build_root_url%>/tpl_images/uk.jpg" border=0>
<%endif%>
and this in sub site_html_link :
Code:
# Set new and pop to either 1 or 0 for templates.
($rec{'isuk'} eq 'Yes') ? ($rec{'isuk'} = 1) : (delete $rec{'isuk'});
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});


Problem is the icon is being displayed for every link, I must be missing something somewhere, any ideas??

thanks, grant
Quote Reply
Re: [grantw] new field in add resource screen In reply to
sorted it uk>>UK :)

cheers for the help, grant
Quote Reply
Re: [grantw] new field in add resource screen In reply to
you do not need the line

($rec{'isUK'} eq 'Yes') ? ($rec{'isUK'} = 1) : (delete $rec{'isUK'});

the reason the other two lines are there are because their value can change under program control. Besides there is no array to delete it from...!

You are going to manually set the value of isUK in the link.db (during the add/modify/validate process) and test it in link.html with the IF statement as shown in your post.

Yep, perl is case sensitive...


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."