Gossamer Forum
Home : Products : Links 2.0 : Customization :

MyLinks.cgi again

Quote Reply
MyLinks.cgi again
How do I tell the mylinks.cgi script to create a second myhome.html file which has a different template (mylinks.html file)so that I can call it to my home page through SSI, like Yahoo bookmark.

Thanks
Will

PS
Here is the long winded question:
For example, at the moment 'mylinks' creates one home html file (using the my_links.html as the template), which has all the links, that have been added by the user.
What I want to do, is create another html file only containing the titles of the links (changing the tewmplate format), so that I can call that file with the users links on to my homepage through SSI, and the have a button, when clicked would open the original created myhome.html.
Basically a simple version of the 'Yahoo personal homepage' bookmark section.

So what I am trying to get to is, how do I tell the script to produce another template but a different layout (having another mylink.html - which contains the layout)?

I think the change would be in this region (but I am not a perl reader)

# Builds the links.
foreach (@c[$start .. ($start + $per_page - 1)]) {
last if ($_ eq "");
$OUT{'links'} .= &site_html_my_link (&get_record (&decode ($_)));
}
}

# Builds the MyLinks page.
print $in->header();
&site_html_my_home ( { %OUT } );


Quote Reply
Re: MyLinks.cgi again In reply to
Unforutunately...I do not think it would be possible without creating a separate MY Links script called something like mylink2.cgi with the same configurations. However, the problem will be maintaining cookies between the two scripts.

Very complex question you have possed and at this time, I do not have a solution for ya.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: MyLinks.cgi again In reply to
yes.. i recommend just making another script that just outputs what you want..

um.. if i had time i would have done it for you.. it's quite simple and i beleive others would find it a great idea as well (it is a very nice feature to give users) so i will leave this one for someone else..

it'd work the same i think if you just called the mylinks.cgi from ssi and change the template to something else that did not have the <html> tags.. so just make another mylinks.. maybe mlssi.cgi or something

Jerry Su
email@jerrysu.com
http://www.jerrysu.com/
Quote Reply
Re: MyLinks.cgi again In reply to
Thanks, I will have a go

Will

Quote Reply
Re: MyLinks.cgi again In reply to
I got this to work without making a different mylinks.cgi. The codes needs to be cleaned up by somebody that knows more than me. I'm a newbie! I was able to get them working on my site during the night, but I changed back to the original codes until I can see how to get around the ssi call. Does anybody have any ideas on how to do this? Anyway here are the dirty but working codes:

You probably need to change the template file names, I have left out the underscore in all of my file names.

The Û is supposed to % d b (without the spaces). This board keeps changing it after I correct it.


Make a template called bklink.html with these codes;

Code:
<a href="<Û_cgi_url%>/jump.cgi?ID=<%ID%>" target="_newwin"><font size="2"><%Title%></font></a>
Make a copy of myhome.html and save as mydetailed

Then change codes in myhome.html to;

Code:
<div align="center"><center>
<table border="0" width="96%" cellpadding="0" cellspacing="0">
<tr><td>
<p>
<font size="2" color="04649C">Total Number of Links Stored: <b><%tot%></b></font></p>

<%ifnot links%>
<p align="center">
<font size="2" color="04649C"><b>You do not have any links stored in My Links.</b></font>
</p>
<%endif%>

<%if links%>
<%links%>
<%endif%>
<a href="<Û_cgi_url%>/mylinks.cgi?detailed=1">Show Detailed Links</a>
</td></tr>
</table>
</center></div>
Then add these subs to site_html_templates.pl (this sub needs cleaning up to take out new and popular. I didn't test it without new and popular)

sub site_html_bklink {
#---------------------------------
my %rec = @_;
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

return &load_template ('bklink.html', {
%rec,
%globals
});
}

sub site_html_mydetailed {
# --------------------------------------------------------
# This routine shows the layout of the MY Link Home Page
my $tags = shift;
print &load_template ('mydetailed.html', {
%$tags,
%globals
});
}

Then in mylinks.cgi sub main find

if ($in->param('add')) { &add ($in); }
elsif ($in->param('delete')) { &delete ($in); }
elsif ($in->param('help')) { &help ($in); }
else { &display ($in); }

And change to;

if ($in->param('add')) { &add ($in); }
elsif ($in->param('delete')) { &delete ($in); }
elsif ($in->param('help')) { &help ($in); }
elsif ($in->param('detailed')) { &detailed ($in); }
else { &display ($in); }

Then I copied sub display and renamed it sub detailed and changed;

# Builds the MyLinks page.
print $in->header();
&site_html_myhome ( { %OUT } );
}

To

# Builds the MyLinks page.
print $in->header();
&site_html_mydetailed ( { %OUT } );
}

Then in the original sub display find the two occurrences of;

&site_html_mylink

To

&site_html_bklink

The span pages routines needs to be taken out, but I'm not sure how to do this. So if somebody one could clean this sub up it would work better.

change all of the links for "My Links" in the mod and on your web site from;

Code:
<a href="<Û_cgi_url%>/mylinks.cgi">My Links</a>
To

Code:
<a href="<Û_cgi_url%>/mylinks.cgi?detailed=1">My Links</a>
Then on your homepage call the mylinks.cgi with a ssi call.

Does anyone know if there would be another way to call this to the homepage without an ssi call. My templates are set on .html and I dont want to change all of them to .shtml or is the a way to change only the homepage to .shtml and leave the others .html?



Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi again In reply to
I have this working on my site now. It can be seen at

http://www.homewithgod.com/


Edited 07/19/00

Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi again In reply to
I modified MyLinks basicly the same as you, and set up an example page that uses an IFRAME to load it rather than SSI.

http://ucmd.virtualave.net/test.shtml

NOTE: Netscape does not support IFRAMES last time I checked. You might be able to use an ILAYER for Netscape, but I'm not sure.

--Drew
~~~~~~~~~~~~~~~~~~~~~~
MUSIC@NonSilent
http://ucmd.virtualave.net/pages/
Quote Reply
Re: MyLinks.cgi again In reply to
Thanks for the info junko, what are the codes for ILAYER and how would you make the if statements for netscape and IE. Also, isn't IE 5 the only browser that supports IFRAME. If this is the case guests with browsers earlier than IE5 would not be able to see them. Do you know what netcape browsers support ILAYER?
BTW, I am using IE5.01, I added two bookmarks and then went back to the test page and they did not show up. Is the test page on the same server?

Thanks for the help.


Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi again In reply to
In Reply To:
Also, isn't IE 5 the only browser that supports IFRAME.
Nope...IE 4.0 supports IFRAME as well.

In Reply To:
Do you know what netcape browsers support ILAYER?
Netscape 4.5 and above.

In Reply To:
Thanks for the info junko, what are the codes for ILAYER and how would you make the if statements for netscape and IE.
Search http://www.netscape.com, http://www.w3.org, and http://www.javascripts.com.

Personally, I think it would be too much trouble to program all browsers for the My Links to be presented on the Home Page...SSI seems like a fine option to me.

Smile

junko,

I just tested your My LINKS test page via IE 5.0 and Netscape 4.6 and it doesn't work.

Regards,

Eliot Lee
Quote Reply
Re: MyLinks.cgi again In reply to
I think I agree with you Eliot, and even if I did use the javascript, approximately 12% of my guests that have even earlier browser would not see anything except a blank table. I don't know if the 12% figure is in line with the rest of the public.

I remember someone asking if the home page could be shtml and the rest of the pages html. I searched for the question all day today and could not find it. Do you know if it can be done?

Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi again In reply to
In Reply To:
I remember someone asking if the home page could be shtml and the rest of the pages html. I searched for the question all day today and could not find it. Do you know if it can be done?
Why would you want different file extensions??? Seems a bit odd to me...

Anyway...it is possible.

If you want to have .shtml for your home page and .html for the rest of your pages in your LINKS generated pages, do the following:

1) Add the following variable:

Code:

$build_reg_extension = ".html";


in the links.cfg file.

Change the variable name if you like to something else...but don't name it build_extension.

2) Then in the following subs in the nph-build.cgi file:

Code:

sub build_category_pages
sub build_new_page
sub build_rate_page
sub build_single_category
sub build_detailed_page
[/red]

replace $build_extension with $build_reg_extension.

I might be forgetting a few subs...but I think you get the drift of my suggestion.

BTW: 35% of my web visitors use web browsers less than 4.0 versions. About 10% use other browsers, including Mosaic, Opera, and Lynx (text-only).

Regards,


Eliot Lee
Quote Reply
Re: MyLinks.cgi again In reply to
Thanks a lot Eliot, I now remember using these codes in on of your other mods or FAQ's on your site. It should be pretty easy to do.

I only wanted to use the shtml on my home page, because I didn't do very good planning when I first build Links 2.0 and I have a lot of hard links in different scripts and throughout my site that would have to be changed and I was afraid I might miss some links to change.

But after you brought this subject up, I'm thinking it might be wise to go ahead and clean all these links up so I don't have this problem again.

Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi again In reply to
In Reply To:
Thanks a lot Eliot, I now remember using these codes in on of your other mods or FAQ's on your site. It should be pretty easy to do.
You're welcome...and the FAQ you are thinking of is located here:

http://anthrotech.com/...inks/faqs/rootbuild/

In Reply To:
I only wanted to use the shtml on my home page, because I didn't do very good planning when I first build Links 2.0 and I have a lot of hard links in different scripts and throughout my site that would have to be changed and I was afraid I might miss some links to change.
Now...I understand...Thanks for explaining your problem. Hard linking is a very bad choice, especially when you are attempting to build a "dynamic" directory.

In Reply To:
But after you brought this subject up, I'm thinking it might be wise to go ahead and clean all these links up so I don't have this problem again.
That would be best.

Regards.

Eliot Lee
Quote Reply
Re: MyLinks.cgi again In reply to
Thanks a lot, I thought this idea would never work

Will
WAVP

Quote Reply
Re: MyLinks.cgi again In reply to
You're welcome wavp and thanks for the good idea. Just keep in mind that I'm new to this and all I did was copy and past codes that were already there and there's probably a lot of fat in them the way that I did it, but they work.

Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi again In reply to
Sorry if it mine isn't working. did you reload the MyLinks area? Right-click anywhere in the MyLinks table and click "Refresh" it should work (at least it is for me -- IE 5.5). Personally, I think SSI is better for this.

--Drew
~~~~~~~~~~~~~~~~~~~~~~
MUSIC@NonSilent
http://ucmd.virtualave.net/pages/
Quote Reply
Re: MyLinks.cgi again In reply to
It's working today. Yesterday I tried refreshing and also tried new window.

Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi again In reply to
In Reply To:
Sorry if it mine isn't working. did you reload the MyLinks area? Right-click anywhere in the MyLinks table and click "Refresh" it should work (at least it is for me -- IE 5.5).
Thanks for the lesson in web surfing!

Wink

Yes...I did all that and the cookie was not created and thus the links did not appear in the My Links test page. Tried it again with Netscape 4.7 this time and it worked...although still not working MIE 5.0.

Regards,


Eliot Lee
Quote Reply
Re: MyLinks.cgi again In reply to
Didn't mean to insult anyone's intelligence by that. I may have to double check the syntax to make sure I haven't flubbed up. Eliot, if seeing MyLinks with Netscape, then your seeing the SSI-called one, in the middle table. I think you just barely missed the change on the test page, where that's pointed out.

--Drew
~~~~~~~~~~~~~~~~~~~~~~
MUSIC@NonSilent
http://ucmd.virtualave.net/pages/
Quote Reply
Re: MyLinks.cgi question In reply to
I have found an error in the modification to Jerry's script that I wrote and cannot figure out how to correct it. I have the first 10 links without the descriptions showing on my home page, that is done with myhome.html. I changed the original myhome.html to mydetailed.html which gives the output the same as the original code did.

When a visitor goes to his mylinks page it is the mydetailed.html, but if he has more than 10 links stored and clicks on page 2 for the additional links it goes to the myhome sub rather than mydetailed.

Page 1 url - http://www.homewithgod.com/cgi-homewithgod/links/mylinks.cgi?detailed=1
Page 2 url - http://www.homewithgod.com/cgi-homewithgod/links/mylinks.cgi?page=2

In the following routine:

Code:
# Builds the span pages.
if ($tpages > 1) {
my $prev = $p-1;
my $next = $p+1;

if ($p > 1) {
$OUT{'span'} .= qq~<a href="$url~;
$OUT{'span'} .= qq~?page=$prev~ if ($prev > 1);
$OUT{'span'} .= qq~"><b>< Previous</b></a> <a href="$url">1</a> ~;
if ($prev > 1) {
for (2 .. $prev) { $OUT{'span'} .= qq~<a href="$url?page=$_">$_</a> ~; }
}
}
else { $OUT{'span'} .= qq~< Previous ~; }
$OUT{'span'} .= qq~<b>$p</b> ~;
if ($p < $tpages) {
for ($next .. $tpages) { $OUT{'span'} .= qq~<a href="$url?page=$_">$_</a> ~; }
$OUT{'span'} .= qq~<a href="$url?page=$next"><b>Next ></b></a>~;
}
else { $OUT{'span'} .= qq~Next >~; }
}
it references $url which is defined earlier as $ENV{'SCRIPT_NAME'}.

Is this where I need to be looking to correct the problem? I have posted my mylinks.cgi here: http://www.homewithgod.com/test/mylinks.txt

Thanks

Jimmy Crow
http://www.homewithgod.com/
Quote Reply
Re: MyLinks.cgi question In reply to
I don't think $ENV{'SCRIPT_URI'} contains the query string. I think you'll need to add the 'detailed=1' parameter after the $url variable.

--Drew