4
votes

I am new to Sitecore and our team is building our first project using Sitecore. As I look through a lot of the tutorials, most of them use XSLT renderings. But I was wondering whether everything that can be done with XSLT can also be done through a Sublayout (e.g. rendering a collection of content)? If possible, I would like to avoid XSLTs for this project.

Thanks!

4
Thanks everyone for your answers!feiyingx

4 Answers

6
votes

There are three main types of rendering technologies used with Sitecore. Together they fall under the "rendering" umbrella term. XSLT is quite unpopular as it is it's own language. WebControls and Sublayouts are similar but different approaches to almost the same thing. Both are implemented in C#.

  1. XSLT - XSL transformation files using the XSLT language. Limited functionality can be implemeneted with these
  2. WebControls - these are C# classes that get compiled into a DLL and used as server controls. Lots of functionality can be done here but the caveat is that front-end code is written in C# using HtmlTextWriters (IMO: "blah!")
  3. Sublayouts - These are User Controls that have both a front-end ascx file and ascx.cs CodeBehind to separate the front-end end from the back-end logic. This is just like a WebControl but separates the design and logic concerns to make it easy to write re-usable components. Any functionality can be created in these and its possible to build entire sites with just sublayouts (in addition to layouts).

For Sitecore's official documentation on these technologies, they're explained in the Presentation Component Reference on the SDN under the section Choosing Presentation Technology.

My opinion: sublayouts are the way to go.

1
votes

Everything that can be done in XSLT can be done in a SubLayout (which is just an ASCX or WebControl). There are in fact some things that are difficult to do in XSLT, and in fact are done better in a SubLayout.

The main reason to do XSLT is mostly for easy output. It's alot easier to output some HTML and display fields, but it is by no means required.

I've been using Sitecore for a year now, and I haven't found any problems where I had to use XSLT.

1
votes

I'd suggest to avoid using XSLT. They seem pretty easy to use, but when it comes to refactoring - they become unusable at all. You can't use tools like Resharper to refactor XSLT's, and there is no way to use Domain Model instead of fields names each time you need to output values.

If you need to add some new functionality to XSLT - there is a big chance it's impossible to do without xsl extensions. And you will end up with lots of CustomXslHelper classes that allow use of Sitecore API and basic .NET operations in XSLT.

0
votes

I think that you'll bump into problems using xslt far earlier then by using the sublayout approach anyway. We started developing websites using XSLT but after a few months started using sublayouts instead. I can't imagine a new web app build on XSLT now. Sublayouts are the way to go, when there are alot of things xslt can't do on it's own which can be done in the sublayout approach easily. On top of that you'll be able to have the benefits of visual studio and it's functions alot more using sublayouts.