Reputation: 1501
I'm using Sitecore 7.1
with MVC
.
I need to get the item ID of the sublayout or rendering used for a particular Sitecore items. Is there a way i fetch list of sublayouts/rendering used by an item in sitecore using .net. Could some post the necessary code for that.
Thanks
Upvotes: 0
Views: 787
Reputation: 2017
Please try below code
Sitecore.Context.Database.GetItem(((Sublayout)Parent).RenderingID);
Also see Using the DataSource Field with Sitecore Sublayouts.
Upvotes: 0
Reputation: 1262
The traditional way to get an array of renderings prior to Sitecore MVC is:
Sitecore.Context.Item.Visualization.GetRenderings(Sitecore.Context.Device, false)
I believe this will return a list of renderings in both a WebForms and MVC context.
Specific to MVC, you can also get a list of renderings by using the current RenderingContext
or PageContext
via:
RenderingContext.Current.PageContext.PageDefinition.Renderings
or
PageContext.Current.PageDefinition.Renderings
Upvotes: 5