开发者

Sitecore presentation: Not using XSLT renderings at all

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 XS开发者_如何学GoLT 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!


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.


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜