auto-inject links?
January 8, 2006 12:12 PM   RSS feed for this thread Subscribe

Is there a way to automatically inject links to corresponding text phrases in Dreamweaver? For example, everytime the phrase, "flashy raver pants" appears, would it be possible for Dreamweaver to automatically make it a link to a pre-determined site? And if not in Dreamweaver, is there another way?
posted by mcsweetie to computers & internet (14 comments total)
You can't do this with search and replace within dreamweaver?
posted by luser at 12:22 PM on January 8, 2006


Or, more explicitly:

find: flashy raver pants

replace: <a href="http://www.flashyraverpants.com">flashy raver pants</a>
posted by namespan at 12:27 PM on January 8, 2006


right, but I plan on doing this for maybe 50-60 different text strings and to search and replace each one would be pretty impractical.
posted by mcsweetie at 12:51 PM on January 8, 2006


Ah.

Is there some kind of consistent correspondence between the text string and the url they point to? If so, regular expression search and replace could probably do your job.

Or do you maybe have a list of text strings and their corresponding URLs in a spreadsheet or database or something? If so, we can probably bring to bear some script foo along with solutions like those found as an answer to this question I asked a while back.
posted by namespan at 1:08 PM on January 8, 2006


Apparently at one point (2002) there was a Dreamweaver extension called "autolink" (as mentioned in this macromedia.dreamweaver discussion thread), but a search of Macromedia Exchange turned nothing up.

Maybe try re-asking this question in the macromedia.dreamweaver discussion groups?
posted by misterbrandt at 1:19 PM on January 8, 2006


Do you have to do this locally? Could you do it with a PHP script (for example)? Seems there is a script called PHPGiggle (main site here, but it's down at the moment, and no google cache). (google results for phpGiggle)

Oh, this is a pretty good page on it. From there: "'phpGiggle' locates user-defined words and phrases in an HTML document or string, and replaces them with links to user-defined URLs."
posted by misterbrandt at 1:29 PM on January 8, 2006


Is there some kind of consistent correspondence between the text string and the url they point to?

indeed! full disclosure: it's for this site. I edit the list of upcoming shows by hand in dreamweaver and I was hoping that someone knew of a way to insert a link to a band's website automatically.

my original plan was to write a simple little PHP script to redirect but that would still require manually inserting links to something like "r.php?NameOfBand." I was hoping someone would know of a macromedia exchange extension to do the trick! but anything that gets the job done will work for me.
posted by mcsweetie at 1:32 PM on January 8, 2006


I doubt you want to completely change your development environment, but Userland's products have had this functionality for well over 10 years and likely still do (haven't used anything of theirs in a dog's age personally) in Manila, their current product. It's called a glossary and takes any text within quotes, compares it to a table, and if it finds the string in the table converts the text to the required link.

I'm honestly quite surprised that this isn't commonplace in other packages.
posted by mikel at 1:50 PM on January 8, 2006


mcsweetie, if you have PHP (and preferably MySql) installed, this is a really simple script. I could set you up if you can't find a dreamweaver extension or someother. Let me know.
posted by miniape at 2:01 PM on January 8, 2006


Here's a quick PHP solution:

index.php
-----------------------
<?php

$pages = array(
"home" => "home.html",
"about" => "about.html"
); //Necessary for security purposes

$search = file_get_contents($_GET['f']);

$replace = array(
"Bathtub Gin" => "<a href=\"http://www.myspace.com/bathtubgin\" title=\"Visit the Bathtub Gin website\">Bathtub Gin</a>",
"Burnin' Doobage" => "<a href=\"http://www.myspace.com/burnindoobage\" title=\"Visit the Burnin' Doobage website\">Burnin' Doobage</a>",
"The Circuit Breakers" => "<a href=\"http://www.circuitbreakers.co.nr\" title=\"Visit the The Circuit Breakers website\">The Circuit Breakers</a>",
"Crank Sanatra" => "<a href=\"http://www.geocities.com/cranksanatra/home\" title=\"Visit the Crank Sanatra website\">Crank Sanatra</a>",
"EESCH" => "<a href=\"http://www.eesch.com\" title=\"Visit the EESCH website\">EESCH</a>"
); //Add more to your leisure

echo strtr($search, $replace);

?>

home.html
-----------------------
<h1>Some bands that I enjoy</h1>
<ul>
<li>Basement Jaxx</li>
<li>Bathtub Gin</li>
<li>Ben Harper</li>
<li>Burnin' Doobage</li>
<li>Carbon Leaf</li>
<li>The Circuit Breakers</li>
<li>Crank Sanatra</li>
<li>David Gray</li>
<li>Dispatch</li>
<li>EESCH</li>
</ul>

Then you access index.php?f=home, and it loads home.html, parses the array and makes any necessary replacements. Hope it helps!
posted by charmston at 4:43 PM on January 8, 2006


Note: click on the file names (index.php, home.html) for a live demo.
posted by charmston at 4:44 PM on January 8, 2006


Wow, I botched this one big time.

Replace:

$search = file_get_contents($_GET['f']);

with:

$search = file_get_contents($pages[$_GET['f']]);
posted by charmston at 4:45 PM on January 8, 2006


Is there some kind of consistent correspondence between the text string and the url they point to?
indeed! full disclosure: it's for this site. I edit the list of upcoming shows by hand in dreamweaver and I was hoping that someone knew of a way to insert a link to a band's website automatically.


Hmm. Probably not consistent enough between bands to really get a lot of mileage out of regular expressions.

Are you working on Windows or on Mac OS X? If Windows, do you have Perl available?
posted by namespan at 6:16 PM on January 8, 2006


may be stating the obvious, but text may have line breaks in the middle of the phrases and unthinking use of regexp may not match those.
posted by andrew cooke at 8:41 PM on January 8, 2006


« Older Any Mac web designers used Rap...   |   Years ago I heard an album mad... Newer »

You are not logged in, either login or create an account to post comments



Related Questions
Should I bother learning Dreamweaver CS3? June 20, 2008
Dreamhacker January 31, 2008
This is why I don't like maintaining other... October 8, 2007
Making Me Some Templates August 21, 2006
Library/information science question(s): My... January 22, 2004