Gossamer Forum
Home : Products : Links 2.0 : Customization :

isLinked - Making hyperlinking an option

Quote Reply
isLinked - Making hyperlinking an option
First and foremost, I am not the writer of this mod, and do not know who should get the credit for it, or if it was derived from several separate mods. I have been trying to get this mod, in various forms to work and with much, much, help from PerlFlunkie have now got it down pat. With very limited perlscript knowledge I was able to modify the scripts and have it all working in under an hour.

Instructions for the islinked mod to make hyperlink an option.

As with any mod, before altering your scripts SAVE AN ORIGINAL COPY to a folder in case you have problems and need to undo the mod you are trying to add!

The scripts you will be modifying are:
In the admin directory, links.def, site_html_templates.pl, links.def and Template.pm. In the templates directory, link.html. In the data directory, categories.db and links.db. Download these files and SAVE an original copy of each before altering them.

Open up links.def script.

Change the following red number on the URL line

# 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|news|mailto|ftp'],

To

# 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, 0, '', '^http|news|mailto|ftp'],

Then add the following at the bottom of your database definitions (same section)

isLinked => [19, 'alpha', 0, 5, 1, 'No', 'No|Yes']

You will probably have to change the number in red to that of the number that follows on from your last definition. Like this.

Gheight => [17, 'alpha', 5, 5, 0, '61', ''],
Priority => [18, 'alpha', 0, 5, 1, 'No', 'No|Yes'],
isLinked => [19, 'alpha', 0, 5, 1, 'No', 'No|Yes']
);

Also you will notice that the last entry does not have a comma after it so be sure to add one to the previous one as shown in red above.

Under the section

# Field Number of some important fields. The number is from %db_def above
Add the following line, but make sure you change the number to match your first entry.

$db_islinked = 19;

Change

# 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'
);

To

# 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',
isLinked => 'Yes,No'
);

Once again notice the last entry does not have a comma so be sure to add the comma in red to the previous entry above.

Save links.def and upload it to the server in ASCII

Open site_html_templates.pl

In site_html_templates.pl:

Find and replace,

sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rec = @_;
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
}

With This,

sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.

my %rec = @_;

# Set new and pop to either 1 or 0 for templates. ($rec{'isNew'} eq Yes') ?
($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
if ($rec{'isLinked'} eq 'Yes') {$linkurl = "<a href=\"$db_cgi_url/jump.cgi?ID=$rec{'ID'}\">$rec{'Title'}</a>";
}
else {
$linkurl = "$rec{'Title'}";
}


return &load_template ('link.html', {
detailed_url =>
"$db_detailed_url/$rec{'ID'}$build_extension",
linkurl => $linkurl,
%rec,
%globals
});
}

Save site_html_templates.pl and upload to the server in ASCII.

Open link.html (in the template directory):

Change,
<a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>
Or whatever your link for the Title / jump.cgi is,

To simply read,

<%linkurl%>

Save link.html and upload to the server in ASCII.

Open categories.db

Add an additional pipe delimiter | to the end of each line.

Save categories.db and upload to the server in ASCII.

Open links.db.

You now will have to add |Yes to the end of each line that is hyperlinked,
or |No to the end of each line that is not hyperlinked.

Example linked: 994|test|http://mysite.com|6-Nov-2004|Food|test|rj|rj@mysite.com|0|Yes|No|0|0|Yes||||Yes
Example Not Linked: 994|test||6-Nov-2004|Food|test|rj|rj@mysite.com|0|Yes|No|0|0|Yes||||No

Save links.db and upload to the server in ASCII.

Update your template.pm file. Instructions can be found here,
http://www.gossamer-threads.com/scripts/resources/Detailed/877.html

Your modifications are now complete and you will have the option to select either isLinked or not linked in your add file.

If you have problems go back and make sure you have added comma's in the links.def file. You will see them in red. Also make sure you have changed the 1, to a 0 in the URL definition.

Quote Reply
Re: [RJLee] isLinked - Making hyperlinking an option In reply to
Thanks for posting your code here for others to use! Trial and error are involved in most mods, but it sure helps to have clear instructions like this.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] isLinked - Making hyperlinking an option In reply to
A minor error in the above instructions:

--
Open categories.db

Add an additional pipe delimiter | to the end of each line.

Save categories.db and upload to the server in ASCII.

--

Skip that step. It is not necessary to do anything to the categories.db file, as it is not affected by this mod.


Leonard
aka PerlFlunkie