Can DreamWeaver do batch conversions to a template?
August 9, 2005 10:26 PM   Subscribe

I'm volunteer webmaster for a site with about 950 pages I'd like to put into a DreamWeaver template calling on an external CSS file. Can I automate this somehow, or at least part of it?

The goal is to clean up the markup, making it validate, and also to make the pages more uniform and maintenance much easier.

The problem is that, as a volunteer, my time is limited and my budget is nil. Converting 950+ pages into a DreamWeaver template is a time-consuming process. I've done a couple dozen so far.

I tried using BKReplaceEm to add the relevant strings to the pages within a subfolder but I screwed it up somehow and left all the documents without any editable region. I went over one line by line, checking the markup, and couldn't find where I'd gone wrong (I did obviously do something worng; I just didn't find what). Correcting the pages took about twice as long as it would have taken to put them into the template normally. So I'm not too keen on trying that again.

Is there some way to specify a path and parameter for DreamWeaver to convert? Better still, is there a way to set up default behaviors for it, e.g. "every page here should have the bits between <body> and </body> moved to the editable region called 'body'; everything between <title> and </title> should go to the editable region called 'title'"?

I've tried searching online for the answer to this, but the feature either doesn't exist or I'm using all the wrong search terms. The manual is also no help (and, for that matter, so is the helpfile).
posted by Tuwa to Computers & Internet (7 answers total)
 
I'd do this without Dreamweaver templates and use a scripting language such as PHP or ASP (gasp!) for the templating system, first of all.

The unix nerd in me says you should use regular expressions to tease out the body and title data, rewriting this as you see fit.

The other problem is that you'd like to manage the styling information seperately from an external css file. This is all fine and dandy, but it still doesn't account for the fact that the existing web-pages that use inline html styling will override the external css file. This probably necessitates your again going back and cleaning up the html pages to make them use your css.

Finally, this is a hard question to answer without specifics about your data. Perhaps it would be easier if you could provide a URL to sample data?
posted by WetherMan at 11:10 PM on August 9, 2005


I agree - sites of this magnitude and complexity aren't really meant to be handled on a page-by-page basis; too much upkeep. Is PHP or ASP (or XSL) out of scope?

The CSS is simple enough, but as mentioned above, you're going to have to run everything through a tool like html tidy to get rid of the depreciated markup, else it'll overrule your CSS.

How many types of pages are you likely to need? You could end up making 100 Dreamweaver Templates, as you're starting to find out.
posted by hoborg at 1:01 AM on August 10, 2005


The short answer is No. You can't apply templates to batches of files - templates are generally meant to be used prior to page creation. This bit me a couple of weeks ago, so you have my sympathies.

I have also found DW somewhat 'unpredicatable' when it comes to what it thinks are changes to uneditable reasons - sometimes it just seems to ignore the fact that it's an editable region until you re-open the page or do something else fiddly.

The best bet without extra coding is to do a folder search and replace title with !-- begin editable 'title-->title (or whatever the syntax is) for title and body and whatever else (don't forget to close them off), then go through file by file and attach your template. This will work (I suspect) only if regions are as definable as that. If the body is split into regions, you're likely going to have to spawn new template pages then copy and paste into them

On the other hand, if *all* you want to do is add a css link globally, you'd be better of doing a folder based search and replace, replacing /title with /title link ref="blah.css" type=... (angle brackets removed)
posted by Sparx at 1:18 AM on August 10, 2005


Response by poster: Funny, I'd been getting the feeling I was chopping down a tree with a butterknife.

I don't know anything about PHP or ASP (or, for that matter, Unix), so I'm probably using "webmaster" lightly. ^_^ I know HTML and CSS.

There are a few main pages that rarely change, then all the rest are archival issues, which are styled the same. It's for a local magazine; the format is typically headline / headline 2 (optional) / author (optional) /author 2 (optional) / publication date.

The inline HTML is a problem, yes. It's very cluttered HTML. I am adding the CSS link, but also having to go through removing HTML. Might almost be easier to redo each month from scratch.

At any rate, thanks for the responses. I'll ask my prof about PHP and ASP once classes start up.
posted by Tuwa at 7:07 AM on August 10, 2005


Dreamweaver isn't apt at managing a large number of files. You should look at writing a script that does this for you.

If you need to convert a bunch of pages, you might try installing Cygwin, which provides unix-like functionality. This would allow you to then write a shell script using regular expressions to insert the necessary CSS includes, classes, id's, etc via the 'grep' tool.

You'll have to put in a significant amount of time upfront, but my guess is a simple script with the include would go something like this: ls *.html -R | grep ().*() \1\n\n\2

If you've never dealt with reg exp's before this will be extremely confusing to you.
posted by creeront at 7:56 AM on August 10, 2005


Course, Dreamweaver has regular expression support as well, I think starting with MX? Maybe someone familiar with them could give you a pointer or two on how to remove the HTML tags that are making your CSS break, given an example file.
posted by hoborg at 10:31 AM on August 10, 2005


Dreamweaver is quite a bit more powerful than most of the previous posts are implying.

I'd start by seeing if there is an extension out there to do what you want. Start at the Macromedia Exchange, then check Project VII and Kaosweaver, and if you can't find one there, try a Google search.

You can definitely use regular expressions in the Find/Replace dialog to do most of what you need. Go pick up a copy of "Teach Yourself Regular Expressions in 10 Minutes" by Ben Forta. You can then use Find/Replace both to add the necessary template markup and to add the link to the CSS file, as Sparx suggested.

But start by looking for an extension. I'd bet there's something out there that will keep you from having to reinvent the wheel.
posted by robhuddles at 11:31 AM on August 10, 2005


« Older A's eat B meat, of course!   |   What magazines do you subscribe to? Newer »
This thread is closed to new comments.