Sitecore MVC Rendering type clarification
Asked Answered
S

2

10

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
Shevlo answered 19/2, 2013 at 12:30 Comment(0)
W
19

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.

Wallop answered 20/2, 2013 at 12:11 Comment(2)
Thank you @herskinduk, very detailed answer. May I ask where can I find above details, as I could not find anything like this on SDN.Shevlo
I believe that the Sitecore MVC documentation currently available on SDN is light on detail. Which is why I posted a very detailed answer for you here.Wallop
E
2

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.

Extrovert answered 19/2, 2013 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.