Taking advantage of Code Hinting

show more Taking advantage of Code Hinting provides you with in-depth training on Web. Taught by James Williamson as part of the Dreamweaver CS3 Beyond the Basics show less
please wait ...

Taking advantage of Code Hinting

In this video, we will take a look at improving the process of actually writing your code. Now, first we will examine how Dreamweaver controls code hinting, then we will discuss code snippets and keyboard shortcuts, and at the end we will talk about efficient tag selection and how Dreamweaver really allows you to do that no matter what working environment that you are in. So let's take a look at our code hinting. Now, you have probably experienced code hinting the whole time you have been working in Code View. If you, for example, come in and enter in the new tag, you will notice that Dreamweaver brings up an entire menu for us of tags to select, and based on what we have typed in it sort of narrows the focus of that, and that makes coding a lot faster. I can just hit Enter right now, and even then when I hit Space, because I have typed in a div tag, I get all of the attributes that a div tag allows us to select. So if I hit id or i for id, it will go down. And if I select that, I hit Return or Enter, and it goes ahead and finishes out that for me, including opening up my codes for me.

And if I had some CSS styles already written, because of the fact that it's a CSS style data type, it would immediately go over to my styles and find my ids and give me a list of them here. So it's really, really smart. It's a really, really efficient way of writing code. But you might wonder, well, where does that come from and can we modify it? The answer is yeah, we certainly can. So I am just going to go ahead and delete that. We are just using a blank file here, so you can just open up your own blank file, we are not working with anything specific. So I am going to go up to my Edit and I am going to scroll down and find my Tag Libraries. There we go. So when I am in the Tag Library Editor, what I can do is I can take a look at all different types of tags. Notice that the top folder are your HTML tags. We have our ColdFusion markup language tags, and so forth and so on, all the way down the gamut. Now, there are a bunch of Tag Libraries in here, and most of the time it's going to have everything that you need for it. As a matter of fact, let's go examine that id tag. If I open up the HTML folder, I can scroll down a little bit until I actually find my div tag. There it is. If I open that up even more, not only can I find the div tag itself, but notice that there are all the attributes to it, and there is a lot of different rules in terms of how it formats the exact code. As a matter of fact, if I select id, you can see that I have got a lot of different class types down here of data types, and CSS style allows me actually browse to there. So how do we actually create our own Tag Libraries? Because if you are like me, you might be adding a lot of XML coding to your day-to-day workflow.

You might be creating a lot of XML files. XML tends to have its own tag structure, and a lot of times for a specific client or a specific job, you will be using a common set of tags for the entire project. Well, I am going to go ahead and cancel out of this. We will come back to it in just a moment. For those of you using the example files, let's go over to the Chapter 1 folder and open up the XML folder. Inside that I have a file here called gallery.xml. Now, this will work with any XML file, so feel free to open it up because we are just going to examine the structure of it. So you will notice that our gallery.xml file starts off with the tag of artists. This is for our art gallery, the CHEEK CHASTAIN GALLERY, so we have a parent tag of artists. Inside that we have an artist tag, and that has a name attribute to it. If we go down through here, we can examine more tags. We see the show tag; that has a date attribute and a name attribute. If I have to code a lot of XML files for this art gallery, I am going to be using those tags and those attributes over and over again, and it would be really nice, instead of having to hand-code all of that, if code hinting could maybe make some of that available for me. So one of the things that we can do is that we can import into our Tag Libraries a Schema file. So what I am going to do now guys is I am going to close this XML file here, and you will notice if you look over in the Files panel again that just underneath my gallery.xml file, I have a file called gallery.xsd. XSD is the XML Schema File. So this is the schema that controls the generation of that particular XML file. You don't have to have schema files in order to make your XML work, they just help describe what's going on inside your XML file, and Dreamweaver can use that to create an entirely new set of Tag Libraries, which can make your life a lot easier. Now, if you have never seen a Schema file, I will open it up real quickly. There is not a lot to it. You can see that we have xs tags in here, and you are simply describing the type of elements and you are describing the attributes that they have, and whether some of them are required or not required, that sort of thing. So for those of you who work with XML a lot, you are probably very familiar with this. If you are not, there are some tools out there that can help you create these Schema files. As a matter of fact, one that I use is Altova's XMLSpy program, which is a great program, and you can download a 30 day trial for that. So I am going to close this out.

So again, if you are not using these files, you can create your own Schema file and follow right along with us. So I am going to go up Edit and once again, I am going to go down to Tag Libraries to open that up again. Now, if you look at the very top of the Tag Library Editor dialog box, you will see a little + symbol right beside Tags; I am going to go ahead and click that. You will notice that we can add new tags to existing sets or add new attributes to existing tags. Well, I actually want to bring in my whole Schema. So I am going to go down here to the DTDSchema selection, and I will choose Import XML Document Type Declaration or a Schema File. Go ahead and bring that in. Now, I get a Browse dialog box, and I can browse. I will go out to my Chapter 1 files, XML, and I will find my gallery.xsd file. So I will go ahead and open that up and click OK. You will notice that now I have an entirely new set of tags right here. It's not a very descriptive name, but it will do for what we are working with right now. You can see that it has a whole family of those tags that we are working with. I am free now to modify these if I want. I can add attributes to them, that sort of thing. Let's go see that in action. I will just go ahead and click OK, and I am going to create a new XML file. So I will just go to File, choose New, and I will just do a new XML file here. Notice that now if I come in and I type in show or sh, show automatically comes up for me. If I hit Return and Space, and you can see as soon as I type the tag in, that now I get those attributes as well. So I can type in name and I can just call this show one, and of course it knows when you have opened a tag, so it will self close it as well. So there is a great advantage, if you are going to be using or writing a lot of XML and you are using your own custom tags, go ahead and create a Schema file based off of that and load them into your Tag Libraries, so that you get the same advantages of code hinting when you are writing your files, as you do when you are writing just regular HTML.

Taking advantage of Code Hinting
Video duration: 7m 20s 11h 10m Intermediate


Taking advantage of Code Hinting provides you with in-depth training on Web. Taught by James Williamson as part of the Dreamweaver CS3 Beyond the Basics

please wait ...