Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The first step in any project using Spry will be to define a data source. So in this exercise that's what we are going to take care of. We are working from the Chapter 5 Directory. So if you are working with the Exercise Files, open current.htm; you can see I have that open. There are several different ways to define a data source, but the easiest way is to actually use the Spry toolbar in the Insert Objects toolbar. You can find that at the very top of your Insert panel, and it's one of the things that they have added in CS3. So we have Common, Layout, Forms, Data, and Spry.
The Spry toolbar contains a lot of different Spry elements, and they are segmented by separators, and on the left hand side, we have different ways of either defining or displaying data on the page. In the middle, we have our Validation Objects, where we can use Spry to help validate Form Objects. On the far right hand side, we have a series of Spry Widgets, and those are going to give you pullout menus and tabbed panels, and accordions, and things of that nature. Now, we are going to talk about using widgets later on, right now, again, the first thing we have to do is to define a data set. So I go all the way over to the first icon, Spry XML Data Set, and go ahead and click on that.
Now, you can use a lot of different things for data sets, but we are going to use XML. So the first thing we need to do is go ahead and give the data set a name. If you are only going to use one data set, you might want to leave the name as the default, but the default is not really that descriptive; ds1 is not that descriptive, so let's give it a more descriptive name. I am going to name it dsShow, and this will be the current show's data source. ds indicates data source, so I am going to leave that prefix on the name. We are going to browse to find our XML source, and if you look in the Chapter 5, Spry Directory, in the Chapter 5 Starting Files, you should find an XML folder. In XML, find the currentShow XML, and click Choose. Any well-formed XML file will work for a data source.
As soon as you browse out to your data source, you want to click the Get schema button. That will parse the data source and it will display all of the elements inside of the XML file. We want to define our data set, not necessarily from the root element, but from whichever repeating child element that we want to use; and in this case we are going to use painting. So I am going to click on the painting repeating element and you can tell repeating elements because they have the plus symbol beside them. From there, I can actually go in and define data types from my Columns. Now, almost everything that we are going to be using in this case is a string data type, so it's just raw text. But there is one that we want to define as being something a little different.
Scroll through your data Columns and find Image/@url. This is the link to the images that we are going to be using. It obviously isn't a string data type. So I will use the Data type pulldown menu, after I have highlighted that, and I will call it image link. So now over there to the right it now says image link. If you want to Sort this data, you can choose which attribute you want to sort it by. So I am going to grab the pulldown menu and I am actually going to sort this by the Name attribute. So the name of the paintings itself will be what we sort by. We will leave the other settings at their default and we will just go ahead and click OK. It's going to go out, grab that information and bring it in.
Now, if your Bindings panel didn't automatically open, you can find that in the Application panel group, but I want you to open us the Bindings panel. I am going to expand mine down a little bit so that I can see everything. You are going to see a binding that says dsShow, and then all those other elements are listed. Now, if you have ever done any dynamic development inside of Dreamweaver, what you are seeing right now is very familiar to you. If you haven't, essentially what we are seeing here is a list of all the elements in the XML file. Displaying these elements on the page would be just as easy as dragging and dropping them on the page, but we have a lot of different tools up in our Spry toolbar to help us with the task of displaying data.
So in our next exercise we will focus on how to get this information to display on the page.
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.