Hey there Janine,
I’m trying to add a Flash file to a template page, but I keep getting the error message “Making this change would alter a region that is locked by a template or translator. The change will be discarded.”
Do you know what I’m doing wrong?
Thanks,
Kate,
You’re not doing anything wrong. This is a common error in templates, and there is a fix that will take care of your problem.
Here’s a somewhat technical explanation of the problem with your template pages, followed by detailed instructions for correcting it. In addition to making it possible to add Flash files to pages created with templates, this fix will enable you to edit the title of your pages and to add AJAX, CSS, and Behaviors to pages created from templates.
The errors for all of these problems are caused because of a missing editable region in the header tag area at the top of the page (more on what that means below).
There are two ways to create templates in Dreamweaver. You can create a new template (.dwt file) directly, or you can create an HTML page and then later save the page as a template. When you create a new .dwt file from scratch in Dreamweaver, the head area of the template is automatically set up as an editable region.
Here’s what caused your problem and why it doesn’t always happen in Dreamweaver. When you turn an existing HTML page into a template (using Save As to change the file to the .dwt format instead of .html), Dreamweaver should make the head area editable — it does that when you create a new template, but not when you save an existing page as a template. This problem can be hard to find because the head region of a page is not visible in the design area, but it’s very important.
If you’re using Dreamweaver CS3, 8, or a previous version, you’ll need to make the head area of the template an editable region manually, and you’ll have to do a little code work to fix it. (Don’t worry, I’ve included the code below so you can just copy and paste it.)
Note: If you are using Dreamweaver CS4 (the newest version), this problem was fixed in most versions. That said, if you’re having this problem and you’re using CS4, the following solution will work for you, too.
To manually add an editable region to the head section of a template so you can insert Flash and other files into your pages, follow these steps:
1. Open the .dwt file and choose Split or Code View so you can see the code behind the page.
2. Find the Head section of the page — it should be toward the top of the page in the HTML code and should look something like this:
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>
Note: Your code may be longer and include other details, such as a real document title instead of Untitled Document, but you want to identify everything between the <head> and </head> tags before you fix it.
3. Dreamweaver creates editable regions in pages by adding a little code that looks like this: <!– TemplateBeginEditable name=”head” –> around whatever area you want to be able to edit. That code is not inserted when you create a template from an existing page, but you can copy and paste the following code into the top of your page to fix it.
4. The easiest thing to do is to replace the entire head area in the HTML code of the original .dwt template file. (Note: You can’t do this in an HTML page created from the template; you need to do it in the original .dwt file. The bonus is that if you’ve already created multiple pages from the template, this should fix all of the pages you created from the template at once.)
Here’s what you need to do:
First, select all the code at the top of your template contained between the <head> tag and the close </head> tag and Delete it.
Then copy the following code and paste it into your .dwt file in place of what you deleted (be very careful to paste this in exactly the same place where you cut the old <head> content. Note that you may want to preserve your title tag or other custom code by saving it and pasting it back into place very carefully. HTML is for the detail-oriented; one missing quote mark and it won’t work. . .
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<!– TemplateBeginEditable name=”doctitle” –>
<title>Untitled Document</title>
<!– TemplateEndEditable –>
<!– TemplateBeginEditable name=”head” –>
<!– TemplateEndEditable –>
</head>
5. Save the page to complete the changes. If you are prompted to apply those changes to pages created from the template, make sure to approve the changes.
6. Although you shouldn’t see any change in the main design area of the page (unless you made a mistake such as deleting the <body> tag), you should now be able to add Flash files and other elements to any page you’ve created from your template, because Dreamweaver will not have an editable region at the top of the code where it needs to save the scripts that make your Flash files, behaviors, and other interactive features work.
7. Once you’ve changed the head code area in the template, you should be able to open any of the pages created from the template and edit the title, insert Flash files, and anything else just as you would any other page . This will also make it possible to add Behaviors that use Javascript, Spry features, such as drop-down menus, and other elements that require adding code to the head region.
Hope that solves your problem, and I wish you all the best with your Web site!
– Janine
Thank you very much.
All the best. It took me several hours to work on this problem until I found this answer on your wonderful site.
I looked up this page source code and everything works like it should now.
Thank again Ms. Janine.
My regards Victor.