Now that we've got context, we can begin to organize and exercise the assets in our Web Property. In this chapter we discuss one of the three primary hierarchies of CMS: the channel. Hierarchies abound. They are used all around us to help us understand and interact with large, potentially complex groups of items. Grocery stores, department stores, hardware stores, stores of all kinds organize their wares hierarchically (see the Hierarchies in Our Lives sidebar).
Many other hierarchy examples could be given (sports, your house, animals, government, religion, and transportation systems, to name a few), but to the point: Hierarchies do make it easier to understand and interact with the objects that they organize. One of the key hierarchies available in CMS is the channel. A CMS channel is used to organize, store, retrieve, and manage postings within our Web Property.
NOTE: In the next chapter, we explore postings at length. For now, think of a posting as a collection of information that we want someone to understand and potentially interact with. In many ways a channel provides functionality similar to a virtual directory in a traditional Web site. It can be used not only to organize information but also to limit access to it. As with all hierarchies, there is one single, master RootChannel called Channels from which every other channel gets its genesis. However, unlike a directory, Channel objects can have properties, can be easily sorted using multiple keys, can be moved or renamed in part or in whole without breaking links in the site, can be easily traversed both up (using the Parent Channel property) and down (using foreach on the contained Channel objects collection) the hierarchy, are typically used to generate dynamic navigation to their contents, and can even be deleted in code. In fact, all of this functionality is available from within the PAPI Context.
NOTE: The ability to move a channel (or a posting) to a new location without any broken links is a feature of CMS called Managed Links. Links are not stored in the database as links but instead as object references. Location is just a characteristic of the object. So, moving an object to a new location simply changes that characteristic, and any link reference will render to the current location. All code in this chapter will refer to a posting based upon a template with the following ASP.NET Web Form controls TextBox, Label, ListBox, and Button using their default properties plus the default console, of course. Follow the steps in the Scratchpad sidebar, in Chapter 24, to re-create exactly the same results shown here, or use your own channels, templates, and postings and just apply the concepts. We will be repeatedly replacing the contents of the Button1_Click function. Also, since we will be working with the channel hierarchy, it will be very helpful to have a structure to traverse. Figure 25-1 shows the structure of the potentially familiar hierarchy as viewed in the CMS Site Manager. This structure will be created later in this chapter in the Creating and Deleting Objects in a Channel section. The structure will be used with the other examples in this chapter. Figure 25-1. Scratch channel hierarchy
NOTE: Using Site Manager to create channels is covered in depth in Chapter 9. Initially, the only channel that has a posting in it is the Scratch channel. |