Log in

View Full Version : Links on multiple pages



Prime
06-05-2005, 05:24 AM
I have a series of pages each containg a link to a web-based database. That database recently changed the way they look up information and my links are no longer valid. I now have to go back and change about 200 pages.
My question is for the future... Is there a way to "pull" a hyperlink's target from another file so that I only have to change the one file from now on each time the online database changes?

Does that even make sense? :)

jscheuer1
06-05-2005, 06:31 AM
There are a number of ways depending upon what is available to you. You could have your links go to a page that has a meta refresh tag on it:
<META HTTP-EQUIV = "REFRESH" CONTENT = "0; URL=http://www.some.com/somepage.html">This would go in the head of the document. This does not work 100% but is pretty reliable. With meta refresh it is a good idea to provide a conventional link on the page as well, should someone otherwise get stuck there. You can use a script but, unless the page you are sending them to requires javascript, I'd recommend against that, as folks without javascript would be lost. A server side include would probably be best. Mike will probably chime in here and explain how that can work. It does depend upon your having a host that allows that. 200 pages is not too many for an editor like Edit Pad Pro which can load multiple files and make global changes to them. There are also stream and/or line editors that can do this from the command line. My favorite is gledit but, it takes some getting used to.

Prime
06-19-2005, 05:02 PM
Okay, here is what I mean...

what used to be
<a href="http://db.tinkersgardens.com/searchcc.asp?PARENTAGE=ALEXANDRA" target="_blank">Search Tinker's</a>

is now
<a href="http://db.tinkersgardens.com/?script=3.6&PARENTAGE=ALEXANDRA" target="_blank">Search Tinker's</a>

As I have over 5,000 pages each referencing a different cultivar, it is a long process to go and change each of them each time the site owner changes his code to look up a cultivar.

I was wondering if there was a way to change my linkage to be something like
look up the link base (found in file "link.txt" or similar) add "ALEXANDRA" then go there.
<a href="part 1" + "ALEXANDRA" target="_blank">Search Tinker's</a>

That way I only have to change "link.txt" each time.

just hoping there's a way.
Tommie

jscheuer1
06-19-2005, 06:22 PM
Not using just HTML (the name of the forum you've posted in) except using the meta refresh method which would work like this:

The link on the 5,000 pages would look something like this:
<a href="redirect.htm" target="_blank">Search Tinker's</a>Then redirect.htm would look something like this:
<html>
<head>
<title>Search Tinker's - Redirect</title>
<META HTTP-EQUIV = "REFRESH" CONTENT = "0; URL=http://db.tinkersgardens.com/?script=3.6&PARENTAGE=ALEXANDRA">
</head>
<body>
If you are seeing this, something went wrong.<br>
Click <a href="http://db.tinkersgardens.com/?script=3.6&PARENTAGE=ALEXANDRA">here</a> to search Tinker's.
</body>
</html>Now, as I said before, a server side redirect would be better but, that is outside my area of expertise except to say that your host must allow you to do it and the method varies from one host to another. Other methods could be employed as well, none of them are strict HTML. A javascript method could be to use this for your 5,000 links:
<script src="searchTinker.js" type="text/javascript"></script><noscript>JavaScript required to Search Tinker's</noscript>Then the file searchTinker.js could look like this:
document.write('<a href="http://db.tinkersgardens.com/?script=3.6&PARENTAGE=ALEXANDRA" target="_blank">Search Tinker's</a>')

Twey
06-19-2005, 07:55 PM
I recommend Kate (kate.kde.org) for a good editor, which is only emphasised by the fact that I'm usually anti-KDE.
If you were to use a PHP script, it would be much easier. All following examples are in PHP, and won't work unless you have PHP installed on your webserver.

<?php $url = urlencode(implode(file('link.txt'), "")); ?>
<a href="<?=$url?>" target="_blank">Link text</a>
Then edit link.txt in the same directory as the script. No redirection required. You could also use a database, but I can't give you appropriate code for your webserver without knowing the database software you have.
If you'd prefer to use a redirect, simply replace the file with:

<?php header("Location: /path/to/newpage.php"); ?>
If you're using a CGI script, rather than outputting "Content-Type: text/html", declare "Location: /path/to/newpage.php".
Note that redirects of any type aren't infallible, although 95% of modern browsers accept them fine. Sometimes a user will disable them.

jscheuer1
06-20-2005, 07:25 AM
If you were to use a PHP script, it would be much easier . . .This is one of the other methods I was alluding to. If it were truly easier though, it wouldn't require the cooperation of one's host. Absent that, I'd say the difficulty level is roughly equivalent. It interests me that you, Twey, mention Kate and KDE. I've got both but, would never use either for mission critical work or anything I didn't want to make into a potential adventure, only because they are so prone to crashing, otherwise they are very nice programs, probably much easier to install (and I'd hope much more stable) on other platforms than Windows (what I and most folks use). What OS('s) do you run?

Twey
06-20-2005, 08:50 AM
Sorry, let me rephrase that: were PHP already installed and set up, it would be a lot simpler and more reliable to use it to achieve the effect required. :)

As mentioned above, I'm usually against KDE (kde.org), for its slowness.
I never noticed a lack of reliability, must just be a Windows thing; perhaps it's also slower on Windows. On Linux it's been officially benchmarked as running at about Windows XP speed, which is still rather slow compared to something like GNOME (gnome.org), which runs (observation only, no benchmarks) roughly twice as fast.
However, I happen to love Kate, perhaps just as a matter of personal taste. Of course, it doesn't beat a good IDE (eclipse.org) for coding projects, but for a small app or script (or something in a simple syntax, for example, HTML), it's my GUI editor of choice.
I run FC4 (fedora.redhat.com) on this machine; I also have a small server (currently down due to lack of a spare ethernet cable) that was running Debian (debian.org) Woody, but I'm thinking of switching it to OpenBSD (openbsd.org). I'm not unfamiliar with Windows, however; I only switched to Linux a couple of years ago.
Are you using Cygwin (cygwin.com)?

jscheuer1
06-20-2005, 09:29 AM
Yeah, Cygwin. It was an [expletive deleted] to install as the support and available files I found were minimal (this is only for a windows install that I am talking about). I finally had to steal a dll from another package (scribus) to get it all to work. Kate reminds me of my favorite Windows based editor, Edit Pad Pro but, seems more full featured and at the price (free for Kate) a real bargain. Anyways, I originally wanted Cygwin so I could have a look at Konqueror. Unfortunately, the version with Cygwin seems really buggy. Could be due to a lack of all the proper support files. Fonts seem limited and many jpeg files are not rendered even though you can get a look at them with Kview. I thought it was a configuration thing but some jpegs come up fine. One of these days I think I'll just archive the whole thing, uninstall it and try reinstalling. With what I learned the first time through I probably can do a better job the second time round.

Twey
06-20-2005, 09:35 AM
Yes, people say that since the software is free, it must not be as good as the more expensive closed-source software, which simply isn't true. Contrary to the reasoning behind pricing Windows Server 2003 Enterprise at $3,999 (http://www.microsoft.com/windowsserver2003/howtobuy/licensing/pricing.mspx) and the strict Microsoft licensing system, people can and do make good, professional-quality software for little or no money.
Konqueror's not that good, however. The folks at KDE have tried to combine too many programs into one. Remind you of anyone? :p I doubt if many people use it as a serious web browser, and if they do, they shouldn't.
If you seriously want to test another OS or a *nix browser, with absolutely no risk of damage to your existing setup, I recommend a liveCD. I tried one myself a little while back, and I was very impressed: it's actually a fully-featured desktop, all packed onto one CD.

Prime
06-20-2005, 03:36 PM
Thanks guys....

Twey
06-20-2005, 03:50 PM
Heh, welcome. Sorry we got a little off-topic :-P

Prime
06-20-2005, 04:55 PM
With your help, and a great reminder about document.write I figured out how to do it.

First I have:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search</title>
<script src="tinker.js" type="text/javascript"></script>
</head>
<body>

<script language="Javascript">
<!--
var culti = "ALEXANDRA"

document.write("<a href=" + tinksite + culti + ">")
document.write("Search Tinker's")
document.write("</a>")
//-->
</script>

</body>
</html>

and then I have tinker.js as:


var tinksite = "http://db.tinkersgardens.com/?script=3.6&PARENTAGE="

So that I just have to change tinker.js each time the coding changes and all pages still work.
It works great, but is this how the HTML should be coded to be considered "proper"?

And sorry, it's not 5,000 pages, it's 5000 references to that site my bad... :o

jscheuer1
06-20-2005, 05:59 PM
This will work many times but, doesn't write strictly correct html so, will fail in some cases:
document.write("<a href=" + tinksite + culti + ">")Due to the fact that the html written would be:
<a href=http://db.tinkersgardens.com/?script=3.6&PARENTAGE=ALEXANDRA>when what is correct is:
<a href="http://db.tinkersgardens.com/?script=3.6&PARENTAGE=ALEXANDRA">One way to have the line written correctly would be to use:
document.write("<a href=\"" + tinksite + culti + "\">")instead. Also, users without javascript enabled will not see much of anything.

Prime
06-20-2005, 06:28 PM
John, you're awesome !! Thanks a heap!