Tuesday, January 12, 2010

Defining Presentation

Last week I wrote about content modeling and inheritance, two of the first topics you encounter when learning Sitecore. Content modeling isn't the most exciting topic. You're really just defining data structures used to store content. There are only so many ways to skin that cat, and so many things that a WCM vendor can do to make this a difficult or complicated task.

Handling presentation is another matter. A vendor can choose to use an existing technology for presentation logic. Or, if the vendor is especially self-confident, it can create its own technology. Sitecore uses the former option, with .NET and XSLT being the specific technologies.

What is presentation?
Just to be sure we're on the same page, I want to explain a little about what the term presentation means when dealing with WCM. Content modeling covers how content is defined. In Sitecore, data templates and items are the main tools used to model content. Content is what gets displayed, and it is separate from how it gets displayed.

Presentation is responsible for describing how content should be displayed. It says, for instance, that the image should go in the upper left-hand corner and the main text should be positioned below it. Presentation is what makes it possible to view content on a website. Content without presentation is like having records in a database without a query to retrieve them.

How is presentation defined?
Sitecore uses "layouts" to specify the overall positioning of content and the format of the content being displayed. The purpose of Sitecore items is to store content. The purpose of Sitecore layouts is to provide a visual representation of items. A layout's format is usually HTML, but it can be pretty much anything you want: XML, PDF, etc.

Uninteresting example of a Sitecore Layout.

Layouts are aspx files. And I don't mean a special kind of aspx file. There is no special class that has to be used to create a layout. There is no special interface that must be used to create the aspx file. No new proprietary language, format, tags or syntax is needed. Sitecore websites can be designed and coded in the same manner as any ASP.NET website.

So layouts are web pages, right?
It seems important to remember that a layout is NOT a web page. Sitecore uses layouts when it needs to display items. A web page - when delivered by Sitecore - is a combination of a layout with Sitecore content. Web pages don't exist inside Sitecore. Web pages are generated by Sitecore.

When you think of a web page, you think of something specific: a web page that describes an event or a place. A Sitecore layout, on the other hand, has nothing specific in it. It can display information about specific events or places, but it doesn't have any content of its own. I'm tempted to describe a layout as a presentation template, but since the word "template" already has a use in Sitecore, I'm not going to do that ;-)

What's next?
I've given an overview of what layouts are, but I haven't explained what goes into layouts. In a way, there isn't anything to explain. Layouts are aspx files, so anything that goes into an aspx file can go into a layout.

But, actually, there is more to explain. Sitecore provides some server controls that make it easy to access content in a layout. In my next post I'm going to explain about these server controls and the advantages you'll gain by using them.

Want to learn more?

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.