10
votes

Could someone help me clarify when to use the following (they all look similar to me and confusing):

  1. Item Rendering
  2. View Rendering
  3. Controller Rendering
  4. Method rendering
  5. XSLT Rendering
  6. Rendering parameter
  7. Any others
2

2 Answers

19
votes

Item Rendering

This is a way to ask a piece of content (an item) to render itself. The content carries information about how it should render.

To the best of my knowledge this is not widely used and not well documented - but I believe the feature itself to pre-date Sitecore MVC.

See more here: http://www.sitecore.net/unitedkingdom/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/06/MVC-Item-Renderings-in-the-Sitecore-ASPNET-CMS.aspx

View Rendering

Basically this is a Razor view. Sitecore provides a default controller and model for the view. The model can be customised by changing the mvc.getModel pipeline.

Use this when you want to render item content that does not require any significant business or presentation logic.

Controller Rendering

With a controller rendering you supply controller, model and view. On your rendering definition item you specify what action Sitecore should use to render the component.

Use this when you need to render content that relies on external data and/or requires significant business or presentation logic. Anything to do with form submission would probably also fall in this category.

Method Rendering

Will output the return value of a call to a static method.

To the best of my knowledge this is not widely used and not well documented - I suppose it could be used for integrating legacy content.

See more here: http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/03/More-Than-Anyone-Ever-Wanted-to-Know-About-Method-Renderings-in-the-Sitecore-ASPNET-CMS.aspx

XSLT Rendering

Renders a Sitecore XSLT on a Sitecore MVC page. This rendering type fills the same space as the View Rendering just using XSLT as the template engine (rather than Razor).

Use this if you have a library of existing Sitecore XSLT components that you don't want to rewrite. Personally I think View Renderings for doing no/low logic components are more appropriate if starting from scratch.

Url Rendering

Renders the response of a HTTP GET request onto the current page.

Use this if you need to screen scrape HTML of another system. Again this could be used as a transition tool when migrating a legacy site. Can be used in some cases to avoid the embarrassing iframe syndrome.

See more here: http://www.sitecore.net/unitedkingdom/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/03/All-About-URL-Renderings-in-the-Sitecore-ASPNET-CMS.aspx

Rendering Parameter

This is not a rendering type and does not provide a facility for rendering anything on its own. Rendering Parameters are used to control the behaviour of renderings. Applies to all of the above rendering types.

2
votes

Hope this will help.

Try reading this reference on Sitecore Presentation component Reference

Read section 2.4 Renderings and it should enlighten you on all aspects of renderings.