Templates: Locking/Unlocking Code Outside HTML Tags Support Product Page

This topic was archived

Still having problems

Asked 03 Nov 2003 04:40:28
1
has this question
03 Nov 2003 04:40:28 Nick B posted:
I purchased your tutorial, but it's not helping me in the slightest and I'm still having problems with my templates. I have in my template an insert record behavior that I want on every page. But I also want to be able to add other server behaviors such as a recordset to other pages. I have in the head of my template file:
<!-- TemplateInfo codeOutsideHTMLIsLocked="false" -->
In fact, it is immediately following the <head> but on it's own line.

In the page based on the template, I have:
<!-- InstanceBegin template="/Templates/index.dwt.php" codeOutsideHTMLIsLocked="false" -->
But it is not being placed in the <head> but instead near the very beginning of the page, right after the DOCTYPE statement. Following it is the insert record behavior that I have on every single page (it's an email list thing).

On the instance page, I go to my server behaviors and try to add a recordset. When I'm done, and press Okay, I get the following message:
"You have made changes to code that is not marked as editable. If you retain those changes, they will be lost the next time you apply a template update to this file. Do you wish to retain the changes until then?" With a Yes or No option.

It doesn't matter if I select Yes or No because nothing happens either way. No recordset is created. I am at a loss. What do I need to do to get this working?

Replies

Replied 03 Nov 2003 05:17:24
03 Nov 2003 05:17:24 Brad Halstead replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I have in my template an insert record behavior that I want on every page. But I also want to be able to add other server behaviors such as a recordset to other pages.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi

What you describe is the exact expected behavior of the template system.

In order to get the template server-side markup to be updated on each page, it needs to be locked using the method you are using. BUT, in order for the child pages to be editable, the template same area that is to be locked needs to be unlocked.. see, it's a catch-22 situation.. you can't have it both ways.

So, what I suggest you do.. is put the common server-side markup that is to exist on every single page as an include and in the template, make sure to remove that special locking markup. Save the template and update the pages.

Then do a sitewide search/replace or manually add the include to the top of every document.

That's the best and easiest method of achieving what it is you desire.

Alternatively... (THIS CAN CAUSE PROBLEMS ) yuo can do the following

Make your template and lock the aforementioned region. Save it. Make all your child pages and save them all. Open the template and unlock this region, save it and update all associated child pages. Then the markup that was in the template region will still exist on the child pages but be editable. You can then add server behaviors as you desire on the child pages. This is a ONE TIME deal.. if you lock it in the future, all added markup in the child pages will be removed!!

Does that help?
Brad

Brad Halstead
Co-author: Dreamweaver MX Templates
Co-author: Dreamweaver MX Magic
Co-author: Dreamweaver MX 2004 Magic
Replied 03 Nov 2003 05:21:36
03 Nov 2003 05:21:36 Nick B replied:
Could I take the common behavior and put it in a library file then just use a server side include pointed to that library item? Does that work with server behaviors? I could place the link to the SSI in a non-editable region while still removing the server behavior from the template, which would allow me to add server behaviors in the instances, right?


Thanks for the very quick reply.
Replied 03 Nov 2003 05:30:11
03 Nov 2003 05:30:11 Brad Halstead replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Could I take the common behavior and put it in a library file then just use a server side include pointed to that library item? Does that work with server behaviors? I could place the link to the SSI in a non-editable region while still removing the server behavior from the template, which would allow me to add server behaviors in the instances, right?<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Library items can't go outside the body region of a document unfortunately.. not that I have been able to get to work reliably anyway.

Some people have luck by putting common server markup between the opening html tag and the opening head tag (which by default is a locked region) and then adding other server behaviors is a snap..

I am unfamilar if there is a logical order to things that needs to be observed.. i.e. if the server-side markup for the connection is inbetween the opening html and head tags, will it run first in order for the server behaviors to work properly on the instance pages.

Perhaps a common working routine might be this:

Make an instance of the template, detach it (no need for it to be updated by the template.

On this page, create your common markup that will be on every page.

Copy this common markup to the include file

The include file is updated and hence the child pages and the template are updated.. there should be no template engine interfering with the additional markup on each instance page.

Does that help?

Brad Halstead
Co-author: Dreamweaver MX Templates
Co-author: Dreamweaver MX Magic
Co-author: Dreamweaver MX 2004 Magic
Replied 03 Nov 2003 19:26:34
03 Nov 2003 19:26:34 Nick B replied:
Got it working great, just like you described. Thank you so much.

I was a bit skeptical about this whole buying an article idea, but now that I see that the included support is so fast and helpful, it's definitely worth the price. Thanks again.
Replied 03 Nov 2003 19:38:44
03 Nov 2003 19:38:44 Brad Halstead replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Got it working great, just like you described. Thank you so much.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Glad to hear it.. which method did you use successfully?

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I was a bit skeptical about this whole buying an article idea, but now that I see that the included support is so fast and helpful, it's definitely worth the price. Thanks again.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

You are most welcomed, thank you for purchasing the article and posting your query. It helps that the auto email notification is enabled by default <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Brad Halstead
Co-author: Dreamweaver MX Templates, Dreamweaver MX Magic, Dreamweaver MX 2004 Magic
Replied 03 Nov 2003 20:49:46
03 Nov 2003 20:49:46 Nick B replied:
I removed the server markup from the template, saved, then did a find and replace to put it back into each instance. Took but a few moments and it's working great now.
Replied 03 Nov 2003 20:54:10
03 Nov 2003 20:54:10 Brad Halstead replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I removed the server markup from the template, saved, then did a find and replace to put it back into each instance. Took but a few moments and it's working great now.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Awesome, thanks for letting me know.

Brad Halstead
Co-author: Dreamweaver MX Templates, Dreamweaver MX Magic, Dreamweaver MX 2004 Magic
Replied 28 Nov 2003 00:24:44
28 Nov 2003 00:24:44 Paul Brown replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
So, what I suggest you do.. is put the common server-side markup that is to exist on every single page as an include and in the template, make sure to remove that special locking markup. Save the template and update the pages.

Then do a sitewide search/replace or manually add the include to the top of every document.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Brad

Are you able to go into a bit more detail about how this is done. Can you say exactly how to create the includes file, which code you insert into the includes file and how you insert the includes file into all the child pages?

If this was added with examples to the end of the tutorial I'm sure it would make for a much better buy. I too like nbostic have been left "wanting" after purchase.

Regards

Paul Brown
Replied 28 Nov 2003 01:56:47
28 Nov 2003 01:56:47 Brad Halstead replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Are you able to go into a bit more detail about how this is done. Can you say exactly how to create the includes file, which code you insert into the includes file and how you insert the includes file into all the child pages?

If this was added with examples to the end of the tutorial I'm sure it would make for a much better buy. I too like nbostic have been left "wanting" after purchase.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi Paul (and others)

Basically all you do is move the server-side markup that is common among all pages currently existing in the region above the opening html statement (usually above the doctype statement if there is one included) to a new file in Dreamweaver, save this new file using a filename of choice, and an extension to match your chosen server language.

Now, back in the template, position your cursor where the server-side markup was (cursor should still be at that position) and make a link to the include file using the menu item of Insert &gt; HTML &gt; Script Objects &gt; Server-side Includes and choose the method you need for your host (file or virtual) and link to your newly created include file.

Now, save your template and update the instance pages when prompted.

Open an instance page to see if the include statement is on the page and that the common server-side markup is infact removed... You *may* have to fix things by remaking the include link and deleting the common markup.

It's beyond the scope of the tutorial how to read server-side markup but that is the jist of it..

Is that enough to work from or would you like a more detailed version and a tutorial update?

Thanks for your feedback
Brad


Brad Halstead
Co-author: Dreamweaver MX Templates, Dreamweaver MX Magic, Dreamweaver MX 2004 Magic
Replied 13 Dec 2003 17:29:01
13 Dec 2003 17:29:01 Paul Brown replied:
Guys

Still trying to get this bl00dy thing to work with no joy...Never had such a nitemare in years of development!!! <img src=../images/dmxzone/forum/icon_smile_angry.gif border=0 align=middle>

Say if I was starting a new site from scratch (wanting dynamic content in both template and instance pages), do I start by inserting...

TemplateInfo codeOutsideHTMLIsLocked="false"

or

TemplateInfo codeOutsideHTMLIsLocked="true"

or

nothing

into the template so I can use the SSI method suggested?

Cheers

Paul
Replied 13 Dec 2003 18:12:12
13 Dec 2003 18:12:12 Brad Halstead replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Say if I was starting a new site from scratch (wanting dynamic content in both template and instance pages), do I start by inserting...

TemplateInfo codeOutsideHTMLIsLocked="false"

or

TemplateInfo codeOutsideHTMLIsLocked="true"

or

nothing

into the template so I can use the SSI method suggested?<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi Paul

If you're starting out with a completely new site and you build your template first, then all your common dynamic data from the template will be added to each new page built from the template, it just won't be updated by the template if you make further changes to the dynamic data of the template.

Nothing needs to be added if you build the template first (properly and completely).

If you make changes to the dynamic content above/below the html tags of the template, then these changes won't propogate to the instance pages unless you add the true condition to the template!

***WARNING***
If you have added any dynamic behaviors to the instance pages that exists above/below the html tags, then it WILL BE LOST if you do this!

So, to overcome this, all you have to do is:

1. Not include the statement at all.
2. Take the dynamic content above the html of the template and move it to an include file that you then reference in the template.
3. Repeat step 2 for the dynamic content that exists below the closing html tag using a different include filename that you used in step 2.
4. Save the template
5. On each instance page do the following:
5a. Delete the dynamic content that is in the top include file that you created for the template and link to the created include file.
5b. Repeat step 5a for the bottom include file.
5c. Save each instance page.

Badda-bing badda-boom you're done.

If you wish to make changes to the include markup for the template (This would typically be something that remains constant on all pages such as a db connection or a recordset that you may use on every page) then do the following:
1. Open the template
2. Move the include files for above/below dynamic content back into the template and delete the include reference.
3. Save the template (DO NOT update instance pages)
4. Make your adjustments to the common markup
5. Move the content above/below the html tags back into the include files, save the new include files and save the template (DO NOT update instance pages when prompted).

***NOTE***
When working with a template and dynamic content that exists above/below the opening/closing html tags it is extremely important to update the base page content in a different session than the dynamic content that exists above/below the opening/closing html tags.

If you are unable to get it working, send me the files offlist as a zip and Ill see what is happening for you if you provide me complete instructions on what you're doing and where it is failing.

Please be aware that I won't be responding right away probably as I have the Flu and am only on my PC cause my wife is out for an hour <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle> I expect to be back online in a few days or whenever she is out of the house.. lol


Brad Halstead
Co-author: Dreamweaver MX Templates, Dreamweaver MX Magic, Dreamweaver MX 2004 Magic


Edited by - BradHalstead on 13 Dec 2003 18:13:16
Replied 18 Dec 2003 12:02:18
18 Dec 2003 12:02:18 Paul Brown replied:
Brad

Thanks for all your help...

I was actually doing everything correct but my DW 6.1 was fcuking up the _mmServerScripts folder and causing an error that I thought was related to the problems outlined above...

An upgrade to MX 2004 solved the problem and now I'm cooking with gas <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Cheers

Paul Brown

Reply to this topic