Gossamer Forum
Home : Products : Links 2.0 : Customization :

adding fields / simplifying 'categories' list

Quote Reply
adding fields / simplifying 'categories' list
hello folks!

i've been browsing the forum for a day or so, scouring for information on a few things that i want to do with my own install of Linksv2. here's what i'm trying to do:

1. adding fields to the "add a link" page.
there seems to be ALOT of threads outlining this, i guess i just need to choose! does anyone have a favorite? as of my posting of this, i'm going to crank through PerlFlunkie's outline, and we'll see how it goes.

2. simplify the "categories" option on the "add a link" page.
there will be many many categories to add links to, and i was curious if anyone knows how to make a giant list simpler in Linksv2.

this little job is my first venture into anything Perl. it's been fun so far... i think Crazy
Wink
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
i guess i should be more specific, incase someone else has done the same thing.

on the "add a link" page, i see these options...

Title
URL
Category
Description
Contact Name
Contact Email

the options that i would like to have are these...

Title
URL
Contact Name
Contact Email
Affiliation
NSF check*
NSF number*
Description
Category
Searchable Keywords

NSF things*: here, i want to have a checkbox. when the box is checked, i want, "this person is funded by the NSF, and their grant number is (this)," to appear with the other link information, below the link. when the box is left unchecked, i would like for this message to not appear.

it seems that from my searches of this forum, that the NSF things would be the roughest. i think the other stuff i could hack. one of my problems, is that i have very limited time to work on this (i have until this thursday night (july 29) to have it running!

thanks Smile
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
For the fields, just make them similar to the other yes/no fields. You'll have to include them in the same place in links.def that you see the others. For the link itseld, you would make it an ifNSF statement to show or not show that info. Can help more later, gotta run...

Appreciate your 'can-do' attitude! Cool


Leonard
aka PerlFlunkie
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
Like so, in links.def:


# Database Definition: LINKS
# --------------------------------------------------------
# Definition of your database file.
%db_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'],
isNSF => [14, 'alpha', 0, 5, 0, 'No', ''],
NSFnum => [15, 'alpha', 40, 75, 0, '', '']
);

# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = 'Links Database';
$html_object = 'Link';
# 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_isNSF = 14; $db_NSFnum = 15;
# Field number to sort links by:
$db_sort_links = 1;
# Field names you want to allow visitors to search on:
@search_fields = (1,2,5);
# System defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%add_system_fields = (
isNew => 'No',
isPopular => 'No',
Hits => '0',
Rating => 0,
Votes => 0,
ReceiveMail => 'Yes'
);
# 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',
isNSF => 'Yes,No'
);

-------

Then in your link.html template:


<ul><li><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>
<%if Description%>
<span class="descript">- <%Description%></span>
<%endif%>
<%if isNSF%>
<span class="descript">This person is funded by the NSF, and their grant number is <%NSFnum%></span>
<%endif%>

<%if isNew%>
<small><sup class="new">new</sup></small>
<%endif%>
<%if isPopular%>
<small><sup class="pop">pop</sup></small>
<%endif%>
<small class="date">(Added: <%Date%> Hits: <%Hits%> Rating: <%Rating%> Votes: <%Votes%>) <a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It</a></small>
</ul>

----

Then in add.html:

<table border ="0" cellspacing="0" cellpadding="0">
<tr><td align="right" valign="top">Title:</td>
<td><input name="Title" size="50"></td></tr>
<tr><td align="right" valign="top">URL:</td>
<td><input name="URL" size="50"></td></tr>
<tr><td align="right" valign="top">Category:</td>
<td><%Category%></td></tr>
<tr><td align="right" valign="top">Description:</td>
<td><textarea wrap="virtual" name="Description" value="" rows="3" cols="42"></textarea></td></tr>
<tr><td align="right" valign="top">Contact Name:</td>
<td><input name="Contact Name" value="" size="40"></td></tr>
<tr><td align="right" valign="top">Contact Email:</td>
<td><input name="Contact Email" value="" size="40"></td></tr>
<tr><td align="right" valign="top">NSF?:</td>
<td><select class="form" name="isNSF" size=1><option>---<OPTION SELECTED VALUE="No">No
<OPTION VALUE="Yes">Yes</select> </td></tr>

<tr><td align="right" valign="top">NSF Number:</td>
<td><input name="NSFnum" value="" size="40"></td></tr>

<tr><td></td><td><input type="SUBMIT" value="Add Resource"></td></tr>
</table>

----

The other changes to add_error, add_success, modify, modify_error and modify_success should be easy to figure out. Also make changes in add.cgi and modify.cgi:


sub send_email {
# --------------------------------------------------------
# Sends an email to the admin, letting him know that there is
# a new link waiting to be validated. No error checking as we don't
# want users to see the informative &cgierr output.
# Check to make sure that there is an admin email address defined.
$db_admin_email or &cgierr("Admin Email Address Not Defined in config file!");
my $to = $db_admin_email;
my $from = $in{$db_cols[$db_contact_email]};
my $subject = "Addition to Database: $in{'Title'}\n";
my $msg = qq|
The following link is awaiting validation:
Title: $in{'Title'}
URL: $in{'URL'}
Category: $in{'Category'}
Description: $in{'Description'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}
NSF Number: $in{NSFnum}

Remote Host: $ENV{'REMOTE_HOST'}
Referer: $ENV{'HTTP_REFERER'}

To validate, please go to:
$db_script_url

Sincerely,
Links Manager.
|;

----

Actually, the isNSF codes are not necessary, unless you have a specific need for it. Just change the link.html to this:

<%if NSFnum%>
<span class="descript">This person is funded by the NSF, and their grant number is
<%NSFnum%></span>
<%endif%>


This will show the text only if there is an entry in the NSFnum field, otherwise it will be skipped.

----

I'm not sure what you want with this:

Quote:
2. simplify the "categories" option on the "add a link" page.
there will be many many categories to add links to, and i was curious if anyone knows how to make a giant list simpler in Linksv2.


Any questions, fire away! Angelic


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] adding fields / simplifying 'categories' list In reply to
wow, thanks for the detailed explanation!

i'm gonna try it out right now.

and, i have another small concern... i recall when the program was being installed, the fella who did it had to convert the files to unix from dos... i think. i'm not entirely sure what he was doing there (something about the return character). should i be concerned with this, as i'm editing the files on a windows platform (wordpad.exe) then uploading them to our unix server?

thanks again!
Quote Reply
Re: [PerlFlunkie] adding fields / simplifying 'categories' list In reply to
   
i'm curious about the syntax on this epxression. in the others, there are single quotes, but for NSFnum, you have listed none. was that on purpose?

thanks!

In Reply To:
Also make changes in add.cgi and modify.cgi:


sub send_email {
# --------------------------------------------------------
# Sends an email to the admin, letting him know that there is
# a new link waiting to be validated. No error checking as we don't
# want users to see the informative &cgierr output.
# Check to make sure that there is an admin email address defined.
$db_admin_email or &cgierr("Admin Email Address Not Defined in config file!");
my $to = $db_admin_email;
my $from = $in{$db_cols[$db_contact_email]};
my $subject = "Addition to Database: $in{'Title'}\n";
my $msg = qq|
The following link is awaiting validation:
Title: $in{'Title'}
URL: $in{'URL'}
Category: $in{'Category'}
Description: $in{'Description'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}
NSF Number: $in{NSFnum}

Remote Host: $ENV{'REMOTE_HOST'}
Referer: $ENV{'HTTP_REFERER'}

To validate, please go to:
$db_script_url

Sincerely,
Links Manager.
|;

----
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
i actually just spoke with the guy who did this. this is what he told me to do...

go to the SSH Shell prompt, go to the directory, type, "dos2unix filename.cgi", and it should work.

and it did!

In Reply To:
and, i have another small concern... i recall when the program was being installed, the fella who did it had to convert the files to unix from dos... i think. i'm not entirely sure what he was doing there (something about the return character). should i be concerned with this, as i'm editing the files on a windows platform (wordpad.exe) then uploading them to our unix server?


however, i don't know if the <%if%> statement is working, because i tried a test addition, supplied it with a Yes and some numbers, and there is only a space. any ideas?

thanks!
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
ok, now two bugs that i'm aware of...

1. the NSF things aren't showing up in the links. it appears in the add, add_error, add_success, and modify's pages, but not when the link is showing on the listing page.

2. neither the isNSF nor NSFnum are showing up in the admin panel.

i'll go through your routine once again to see if i've fouled something up Smile
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
Well, you've been busy!

Sounds like you may have uploaded incorrectly, which will put returns at the end of the lines, which unix does not like. There are scripts that will strip those out, sounds like what you used. Just be sure to upload in ascii, you won't have that problem. WordPad can cause problems, better to get a plain text editor, try www.textpad.com or similar.

My bad, the single quotes should be there:

NSF Number: $in{'NSFnum'} not NSF Number: $in{NSFnum}


Do you already have some links in the link.db? If yes, did you add two delimiters | | to the end of each one? I just went over this in LordStryfe's thread. You should have 15 pipes (delimiters) for each link entry (using the mod as shown above).

Let us know how it goes! Sly


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] adding fields / simplifying 'categories' list In reply to
ok, well, i added the delimiters, then added two more fields, added more delimiters, dos2unix'ed all my files, made more changes, dos2unix'ed them all again, did those previous two steps about ten more times...

Shocked

...and it works!! i wish it was public so that i could show you the results. i'll have to stay in touch, and post again when it's live.

a tremendous thanks! Cool
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
persistance => education

While it can drive you crazy, it sure is fun when it finally works!! Glad you got it going!
Wink Cool Smile


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] adding fields / simplifying 'categories' list In reply to
well, it still works, but i've noticed that during the build process, there is an error...

Code:
CGI ERROR
==========================================
Error Message : unable to open home page: /home/coursewr/public_html/pages/index.html. Reason: Permission denied
Script Location : /home/coursewr/public_html/cgi-bin/admin/nph-build.cgi
Perl Version : 5.008003

in the staggered build mode, i've found that this error occurs when it tries to build the "cool pages" section, which is a function that we do not intend to include. how can i remove this? we won't be using it anyways :)

thanks!
Quote Reply
Re: [wildealien] adding fields / simplifying 'categories' list In reply to
This type of problem can often be fixed by deleting all the public pages that Links creates, then rebuilding, which will replace them all. A quirk...

There is a thread covering how to stop the new, cool, and rating pages from building:

http://www.gossamer-threads.com/...view_threaded#218198


Leonard
aka PerlFlunkie