I've created previous/next links using a different approach. Doing it
with BBEdit's search and replace would result in a static sequence of
pages that's fairly inflexible. My pages and links aren't generated
from a database or CMS either.

What I did was to write JavaScript code that runs at load time, looks
at the filename of the document it's loading into (which includes a
numeral corresponding to its place in the sequence, such as
foo_06.html), and then generates the previous and next links
dynamically. I like this arrangement because it's very flexible -- if
I want to insert or reorder some pages, all I have to do is change
their filenames, without even looking at the code inside the
documents. Of course if the client has JavaScript disabled the links
won't get written, so I'll probably rewrite the whole thing as a PHP
include one of these days.

I'd put the whole script up here for you, but it's spread out in
various places in my central JS file (since parts of it are reusable
utility functions I wrote) and tied in to the specific IDs and
structure of my pages. However, here are some JavaScript snippets that
might help get you started:

var seriesBaseLocation =  location.href.split(/\d\d\.html/)[0];

var currentPage =
parseInt(location.pathname.match(/\d\d\.htm/)[0].split(".htm")[0],10);

if(currentPage < 11) { previousPage = seriesBaseLocation +      "0" +
(currentPage-1) + ".html";}
        else {previousPage = seriesBaseLocation + (currentPage-1) + ".html";}

...and so on. (I don't really use those variable names but I wanted to
make it self-explanatory.) It all seems to work well.

Instead of writing the code yourself, I imagine some of the common JS
or PHP libraries might have a similar function; it seems like a pretty
obvious thing to use an include for (either server-side or
client-side).

Hope this helps.
-- 
Lawrence San

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to