Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Creating templates is a two-step process. First, you save the file as a template, and then you create its editable regions. When a file is first saved as a template, everything on the page is initially locked down. Without defining editable regions you wouldn't be able to build any new pages using your template. In this movie, we're going to take the source file that we created in our last movie, save it as a template, and then go in and define all those editable regions that we're going to need for our pages.
So, I'm going to go over to my Files panel and I have defined the 13_02 folder as my root directory. And I'm going to go in and find the main_template.htm. So here is the page that we structured last time. You can see all the placeholders we placed in, Region ID, breadcrumb, Page Heading, and notice that as we click in the links, they all have that baseLink class applied to it. So baseLink has been applied to all those and finally remember in our trivia, we have that trivia body section down there.
So this page is ready to go and we're ready to make a template out of it. So what we're going to do here is go to File and choose Save as Template. Now you don't have to have a page that's fully structured to save as a template. It doesn't really matter. You can take a fully finished page and save it as template, or you can start from scratch. Whichever workflow is going to be faster for the type of site that you're creating. So, I'm going to choose Save as Template. Now, you're going to see something little different here. We don't get to browse to a directory. We just get this dialog box that comes up and says Save as Template.
It asks us which site we want to save it to. In this case, Explore California. It also shows us that currently we don't have any templates in our site. So we can go ahead and save this page as anything we want, but there is a reason that we named it main_template. That is the name that I want for this template, so I'm just going to leave that name as it is. Now, it's always helpful to type in a description for your template, especially if you're going to have multiple templates. So, I'm just going to call this one top level Explore California template.
So, a brief description that describes the type of pages that should be created using that template is a good idea. I'm going to go ahead and hit Save. It's going to ask you if you want to Update Links. Definitely say Yes. Now, let's take a look at why. If you look over your Files panel, we have a folder over there that we didn't have before. This Templates folder was just created and if we look inside of it, we can see the template that we just created, main_template.dwt. Dreamweaver templates use the .dwt extension.
Now, this Templates directory is a very important directory. You don't want to move this around, change it, and delete it, anything like that. Dreamweaver is going to reference the files in this directory for all the pages that you build off the templates. So, it's really important that this remains on the root and that you don't modify it in any way. Now, when you go to upload your pages, you do not need to upload this to your site in order for it to work. Templates really only apply to the local development environment and aren't required by the remote server in order to work properly. Okay, so now that we have our template, the next thing we need to do is go through and add some editable regions.
If we just saved our template right now and closed it and try developing pages off of it, we could build pages, but we wouldn't be able to change anything because everything would automatically be locked down. Creating an editable region is really just as simple as highlighting the regions that you want to be able to change in your template pages and making an editable region out of them. Now, there are a couple of things you have to take into consideration when you're creating a new editable region. Let's create our first one and we'll talk about some of those. Go ahead and highlight the text Region ID.
That's going to change on every single page, so we need to make an editable region out of that. So with that highlighted, I'm going to go up to my menu and go to Insert > Template Objects > Editable Region. Note the keyboard shortcut, Ctrl+Alt+V or Command+Option+V on the Mac. If you're going to be doing a lot of template creation, that's a good keyboard shortcut to know. So, Insert > Template Objects > Editable Region and we're going to be prompted to go ahead and name this. All editable regions have to have a unique name, so we're going to call this one regionID.
I want to make sure that follows your standard naming convention, single word. You can use underscores or Camel Case naming or whatever your personal preference is. I'm going to go ahead and click OK, and there is our first editable region. Now, notice that the editable region is surrounded in sort of this blue outline and kind of has a blue tab. You can change the color- coding on those if you'd like. Locked regions have one color and editable regions have another, but if you're going to change them, you can do that through the preferences. If you're in a team, make sure everybody is using the same color, because you don't want to confuse people if you're using one color for editable regions, and another for locked.
Okay, so the editable region we just created is pretty unique and what we've done is we've created an editable region within a tag. So, our editable region now exists only within this h1 tag. You can see there is a little tag called mmtemplate:editable, and if we'll look at that in Code View or Split Screen View, you can see the Dreamweaver uses these comment tags to identify a template structure. So if you ever look at the code, you can see where editable regions begin and where they end. Well, this editable region is inside the heading.
That means that whoever creates pages based off this template won't be able to modify the heading at all, only the contents of the heading. That's a really big distinction. Do you want to give people the ability to change an entire region, or do you want to give them just the ability to change the text within a specific heading or paragraph? You've got the ability to narrow that focus, or you have the ability to create a really large area like we're about to do next. So, next we want the remainder of our main content area to be an editable region. Now our breadcrumbs will be inside an editable region, but they are also going to be part of something called an optional region, so we're going to be creating them just a little bit later as we tackle those.
Okay, so I want you to place your cursor just below the breadcrumbs and when you do that you'll probably click and select this div tag called mainArticle. Once you have that div tag selected-- an easier way to select it maybe would be to click inside of it and then choose the mainArticle-- you want to switch over to Code View. You want to make sure in Code View that you've lines 48 through 51 highlighted. You want the entire div tag highlighted. The reason that we're doing this is we want the entire div tag to be contained within an editable region. This way you could change that div tab, you could add tags underneath it, and you wouldn't be restricted to only changing the contents of the div tag, so that's very important.
I'm going to switch back to Design View. I'm going to go up to Insert > Template Objects > Editable Region and we're going to name this one mainContent. So now we have an area where our body copy and our page headlines can be entered into and also since we have the entire div tag as part of that editable region, we could add additional div tags afterwards if the page structure demanded that. Okay, let's scroll down and we're going to add our sidebar as an editable region and we're going to do that in a very similar fashion. Just go in and click anywhere inside the sidebar and then select the sidebar itself using the Tag Selector right there.
Now, for this one, we want all of our content within the sidebar to be editable, but we don't want the div tag itself to be inside of an editable region. So, sometimes the best way to do that is to go into Code View. So, I'm going to switch to Code View, and there I can see the beginning of the sidebar and I can see the end of the sidebar. So, what I'm going to do now is I'm going to start selecting at line 55 and I'm going to scroll all the way down to line 70. So make sure that you have the div "specials" highlighted, and the closing div on line 70 highlighted. But the ending div tag for the sidebar, which is on 71, and the beginning div tag for the sidebar, which is on 54, you don't want those highlighted, because we only want our editable region to be inside the sidebar div tag, not surrounding it.
So again, I'm going to go back up to my Design View and I'm going to go up to Insert > Template Objects > Editable Region, and we're going to just call this one sidebar. Now, it may seem like we were having to be extremely precise there and well, we were. When you create editable regions, you really need to think about the structure of the page and what portion of that region needs to be editable. Is it just a headline that needs to be editable? Is it an entire region or is it the contents of the div tag? When you go to make your editable region, you always want to double-check to make sure that you have the proper area highlighted.
Sometimes you might have too large of an area highlighted and sometimes too small of an area highlighted, and the best way to verify that is just to go into Code View, find out precisely which tags you have selected, and what portion of your page is going to be within that editable region. Taking the extra time to do that as you're creating your templates is very important because it's going to save you a tremendous amount of time a little bit later on. So now we have three initial editable regions. We have the regionID, the mainContent, and the sidebar. Go ahead and save your template and Dreamweaver is going to give you a little message. Now, this really isn't an error message. This is more of just letting you know.
Notice that it says "You placed the editable region "regionID" inside a block tag." That's the heading that we're talking about. "Users of this template will not be able to create new blocks in this region." Meaning you won't be able to add paragraphs or new headings up there. "Move this region outside the block tag if you want users to be able to do this." So in this instance we meant to do that, and we want that capability, but it's fantastic that Dreamweaver shows us this message because if that is not what we had intended, or maybe we selected too small of a region, Dreamweaver is going to give us that feedback so that we know, oh, I didn't mean to do that, I need to modify that editable region.
As it is, that's exactly what we wanted to do so we're going to go ahead and click OK. Now, every time we save this template we're going to be faced with that particular message. So, if it becomes annoying to you after a while, you could turn it off. I like leaving it on because it just gives me the confirmation that yes, indeed, I did select that area and that is what I meant to do. Or if I didn't mean to do that, it's always nice to have Dreamweaver reminding me of the fact that editable region might need to be changed. So now I'm going to go ahead and click OK. Now, we're almost done with creating our template, but if we take a moment to think about how we're going to build our pages, there are still two items that we need to be concerned with.
Our navigation needs to change to show that current page and either to hide or show the sub-navigation based on which section of the site we are in. We also need to either hide or display the breadcrumb navigation based upon the page that we're building. So, first we'll create a means of defining what current page we're on and what type of page we're building through the use of editable attributes. Then we'll move on to controlling the visibility of content through the use of optional regions.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.