Tuesday, February 9, 2010

How Presentation Controls Are Used In Sitecore

My last several posts have covered controls (.NET and XSLT). The purpose of controls are to allow presentation logic and functionality to be reused. One thing I haven't explained is how controls are actually used.

Controls can be used in two ways. One way is probably pretty obvious: you can put presentation controls directly in a layout using web controls. Sitecore provides web controls for positioning sublayouts and renderings. Since Sitecore web controls are already ASP.NET web controls, they can be used as-is.







Positioning presentation controls directly in a layout is sometimes called "static binding". The words refer to the idea that the controls are positioned in the layout in a way that does not change.

Which leads us to the second way to position controls: dynamically. Using dynamic binding, a control is positioned in a layout by a content editor rather than a developer. If you're comfortable with the concept of variables, the approach Sitecore uses will make perfect sense:
  1. Developer creates a "placeholder" in a layout. The placeholder is given a name.
  2. Developer specifies the controls that a content editor will be allowed to put into the placeholder.
  3. The content editor selects placeholder he wants to position a control in.
  4. The content editor selects the control he wants to drop into the placeholder.
Step 1 involves inserting a web control into the layout. Step 2 involves configuration inside Sitecore. Steps 3 and 4 can be performed in a number of ways. The following video demonstrates how to do it using Page Editor.



Now, there is a little more to working with placeholders than the 4 simple steps I listed above. The missing piece is understanding how Sitecore knows to you the layout in the first place. That is key because the placeholder is defined in the layout.

What's next?
I just tipped my hand, but defining content and presentation only get you so far. In order for either to be useful, they must work together. My next post will cover how you tell Sitecore which presentation should be used for which content.

Want to learn more?

3 comments:

  1. I noticed that in Visual Studio you opened the Website. Since Sitecore does not directly support the website model, but does support the web project model, this difference is important, especially if you need to compile your web user control (sublayout).

    ReplyDelete
  2. Thanks Seth. I fixed the video so it no longer suggests you should open the website rather than create a project.

    ReplyDelete
  3. Hi Adam,

    What do you mean by "static and dynamic binding". So that can allow control reuse ? or only static ! ?

    Positioning presentation controls directly in a layout is sometimes called "static binding". The words refer to the idea that the controls are positioned in the layout in a way that does not change.

    Which leads us to the second way to position controls: dynamically. Using dynamic binding, a control is positioned in a layout by a content editor rather than a developer. If you're comfortable with the concept of variables, the approach Sitecore uses will make perfect sense:

    ReplyDelete

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