Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Our template is almost ready to use, but we need to account for the fact that not every page is going to need the tours, resource, and explores sub-navigation. And the breadcrumbs are also not going to be needed for top-level pages. As such, we need to place those elements inside what we call optional regions. Optional regions are just that. When you create a brand-new page based on the template, you get to decide whether that content will be added to the page or not. They are a great way to create amazingly flexible templates.
So we have our main_template open. And I have opened this from the 13_04 templates folder. So the first thing we are going to do is create our optional regions out of our navigation. I am going to scroll down into my sidebar and navigation area over here. And I am just going to tackle these guys one at a time. Now it's really helpful if you have some existing structure that you can use to select the region that is going to be used as the optional region. And in this case it's going to be really, really easy for us. I can click anywhere inside the sub-navigation.
And I want to use my tag inspector to sort of go up through the tags starting on the right-hand side until I find this. I'm looking for an unordered list ul tag with the class subNav applied to it. When I click that, notice that I am selecting all of those sub-navigation links. So any of our sub-navigation,s the tours, explores and resources sub-navigations, are all inside an unordered list with the class subNav. So it makes it easier to identify, find, select and now encase that within an optional region.
So with that selected, again the easiest way to do that is to use the Tag Selector. I want to go up to Insert > Template Objects > Optional Region. So the first it's going to ask me is what I want to name this optional region. And this one, I am just going to call it toursSubNav, again all one word, fairly descriptive. And notice that we have the option of either showing that area by default or not. What that means is when we create a new page office template should that be on the page, or do we need to explicitly tell Dreamweaver that we want that on the page? I am actually going to turn Show by default off.
I don't want that to show. Only when we are building pages in the tours section will we need this menu. So I am going to turn it off by default. And then when we get into building pages on the tours section, I can enable it anytime I want. Now there is an Advanced tab here where you get to put in template expressions. Now these expressions might allow you to basically show them if other conditions on the page are shown as well. You can kind of daisy chain some of these optional regions together to create a incredibly complex pages. For what we are doing in our template however the Basic tab is all we need.
I am going to go ahead and click OK. Now notice that this is inside of sort of a light blue region and it says "if." So this is what we call a conditional region, meaning it's only going to be visible if the conditions for its visibility are met. I am going to scroll down and I am going to find the resources subNav, which is right here, Tour FAQs, Terms and conditions. And once again I am going to use the Tag Selector to find that you ul with the class of subNav and I'll click to select it. So remember each of those are in exactly the same type of element making them very easy to select and to convert.
Next, I am going to go up to Insert > Template Objects > Optional Region. And I am going to call this one resourceSubNav. And just as we did with our tours I am going to make that invisible by default. And when we want to see it well have to explicitly state that we need it. I'll click OK and repeat the same procedure with the Explore sub-navigation. So click inside of it, click the unnumbered list then go up to Insert > Template Objects > Optional Region.
And this one is going to be explorerSubNav. Again deselect the Show by default. Click OK. Well we are almost done. The last optional region we have on our page is a breadcrumb. And if I click inside that breadcrumb, the structure of it is pretty easy for me to see. It's within a paragraph, which is also within the mainContent. Well, remember mainContent has two editable regions already in it. So the paragraph is really the only thing we need to show or hide based on whether we have breadcrumbs or not. So I am a going to select the paragraph tag by clicking on the p tag right here.
So use your Tag Selector to make sure you get the tag and the contents of the tag. And again I am going to go up to Insert > the Template Objects > Optional Region. Now I am just going to call this one breadcrumb. And I am going to turn Show by default off. Now when I click OK, it seems like our work here is done, but it's really not. Breadcrumb needs to be editable. Currently, it is not within an editable region. Our regionID is where our mainContent is, but breadcrumb is not. So don't assume that optional regions are editable because they're not.
Optional regions are going to show or hide regions on the page, but they're not going to give you the capability of editing the interior contents. So if you need that to be editable, then you need to go ahead and encase that within an editable region and we are going to do that now. Now I could highlight the text breadcrumb and make an editable region out of that. But there's no guarantee that I am going to get all of it or even an individual link. So I am going to do exactly what I did when I created the optional region. I am going to use the Tag Selector to select the paragraph tag. And then go up to Insert > Template Objects > Editable Region.
I am just going to call this editable region crumLinks and click OK. Now you can do that in any order that you like. You cold place the editable region there first and then place the optional region around it or you could do it in the way we did it, this time, the optional region with the editable region around it as well. It is never a bad idea to check Code View and make sure that it is doing what you want it to do. Notice for example that we have our conditional statement here and now it surrounds the editable region as well, and that's perfect. We want our editable region to be inside the optional region, and that is exactly what is going on here.
Now we have our editable regions, optional regions and editable attributes. So even though we have a fairly simple page layout, we have a fairly robust and complex template. Our template is lean, it's flexible and it's going to allow us to create almost every page in our site. Well, that means we are ready to create some new pages with our template and we're going to tackle that next.
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.