Neat idea for showing Sitecore Sublayouts

Sometimes simple things make life easier. Here’s a good tip from Brian Pederson on locating sublayouts on your webpage. The short of it – in your layout page, insert the path to your sublayouts. 

Note that the insert function needs to be recursive, as you could have UserControls inside the sublayouts (which are, of course, UserControls themselves).

Some thoughts about possible improvements:

  • It might be nice to be able to use a query string parameter (e.g. ‘debug=yes’) to turn this on for a particular page.
  • I wondered about using compiler directives to control whether the debug information was shown or not. This would work best with pre-compiled sites, I’d guess.
  • Our projects often use a standard BaseSublayout class for all the sublayouts – which might be a good alternative to injecting the comments in. Instead, have the BaseSublayout render it directly. That would remove the problem of inline controls (see below).
  • As mentioned in the comments on that article, I wondered if there was a pipeline in Sitecore we could modify.

I’m not entirely sure I like the way that inline controls could raise exceptions (see the comments of the post) as this is an expensive operation, but I guess that’d be fine in development.

Edit: I have had some fun with these on a page that uses an UpdatePanel, just as a warning. I’m not quite sure what the problem is, but if I remove the injected comments, it goes away!

Neat idea for showing Sitecore Sublayouts

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.