Video: Defining page structure for Sliding Panels

At their heart, all Spry widgets are merely structured DIV tags controlled by JavaScript and cascading style sheets. Before we add the JavaScript and CSS to our page, we'll start by defining our widget structure. Some widgets can get fairly complicated so starting out with just the basic framework is a good way of making sure the widget will function as desired. So I've opened of the details_start.htm from the Chapter 4 directory. If you're following along with me with the exercise files, go in the Chapter 4 folder and you'll find details_start.

Defining page structure for Sliding Panels

At their heart,all Spry widgets are merely structured DIV tags controlled by JavaScript and cascading style sheets.Before we add the JavaScript and CSS to our page, we'll start by defining our widget structure. Some widgets can get fairlycomplicated so starting out with just the basic framework is a good way of making sure the widget will function as desired.So I've opened of the details_start.htm from the Chapter 4 directory. If you're following along with me with the exercise files,go in the Chapter 4 folder and you'll find details_start.

So a lot of what we'll be doing is hand coding. So I'm going to switch over to Code View,and I can collapse my panels so that I can see my code a little bit better,and I'm going to scroll down to line 45.Now on line 45,we can see that we have a DIV tag called panelContainer.This is going to hold our Spry widget and the reason that we are going to encase this in another DIV tag is so that we cangive it a little additional styling.So I'm going to hit Return and go down to line 46; it's going to be all on its own line. And I'm just going to create a new DIV tag.

So we'll do DIV and the ID for this one is going to be detail,capital S, Slide, number one.We're also to be using classes extensively with this widget. We're going to assign a class attributeof Sliding Panels.And we'll close that and hit Return and close our DIV tag. Now, you might be wondering as we create this structure where I'm getting these ID names and class names from. I'm getting them from the external JavaScript fileand external CSS file. So as you're structuring and building your own widgets, pay very close attention to what ID names and whatclass names are being either passed into the JavaScript function or assigned dynamically through the JavaScript function so that you'llknow what to make them. And actually all the tutorials, all the sample files should be very clear as to how that structures going to be set up.

So now we have a DIV tag that's going to surround all or our Sliding Panels. I'll go ahead and we'll just create another DIV tag to holdthe Sliding Panel's content group.So we'll do another DIV tag inside of our detailSlide1and it's only going to have a class attribure and it's class attribute is going to be capital S, Sliding,capital P, Panels,capital C, Content,capital G, Group. So that's a long one.SlidingPanelsContentGroup.Most of the names make sense if you think about them. If you really pay attention to what you're naming everything, it should makea good bit of sense. So we're going to go ahead and close that DIV tag as well.

So right now our structure has an outer DIV tag called detailSlide1,and we have an inner DIV tag with a class attribute of SlidingPanelsContentGroup.After we're done with that, we need to insert a DIV tag for each panel of content and in our exercise, our widget will havefour panels for the four products we're going to be highlighting.We need to create four of these. So I'm going to create a DIV tag inside my SlidingPanelsContentGroup and I'm giving it an ID of panel0.That ID is one that I came up with.That's not required for our Sliding Panels widget.

Dreamweaver is going to build an array of these panels in JavaScript so obviously most arrays start counting at zero so by callingthe first one panel0, I'll understand which one it's talking about it if I ever having to cycle through by element ID andfind out what it is.Now after that, I'm going to type in class and this one is going to be SlidingPanelsContent.Obviously, spelling and capitalization really matter here , so capital S, capital P, capital C and notice thatpanel's plural, content.Now I'll go ahead and put some placeholder content inside of this so I'm just going to type in'First Panel Content' before I close the DIV tag.

The same structure holds for all these so I'm just going to copy this codeand paste it.The next thing I have to do is change the ID from panel0 to panel1.The class remains the same. So that's one reason why we're using a class here; we can apply the class over and over andover again, no matter how many panels we have.I'll change the placeholder text to Second Panel Content.Just go ahead and do that a couple more times,changing it to panel2and then Third Panel Content,and then finally changing it to panel3and then Fourth Panel Content.

Now the one thing that might trip you up here a little bitis the fact that we're starting our IDs at zero, but then we're saying first, second, third and fourth panel content.So keep in mind that panel3will actually hold the fourth panel content.Alright I'm going to go and save the fileand I'll switch back over to Design View.I can clearly see the structure, so just below my thumbnails, I have a DIV tag that holds the first panel, second, third andfourth panel content.We now have our clean, structured markup necessary to create our Sliding Panels.Before adding the necessary scripting, we'll go ahead and replace our placeholder content with the actual content of the panels.

This process is simplified considerably by having the structure already in place.

There are currently no FAQs about Dreamweaver CS3 Projects: Creating Custom Spry Widgets.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Already a member ?

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships.
Learn more

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.