NOTE: This property is now obsolete.
Use State.CustomLayout instead
Gets or sets the ID or name of the current layout.
The ID or name of the current layout.
The current layout is the layout that will be rendered by the web engine. This is by default the layout of the current item.
The default layout can be overridden by setting the current layout before the web engine starts. This can be used to build the layout programatically in conjunction with AddRenderings and RemoveRenderings. Normally programatic layouts are built in global.aspx which executes before the web engine.
When programatically setting the current layout, the State property CurrentLayoutChanged is set to true.
By default the current layout is set from then request query string argument "layout". This is argument is set to the layout of the current item by the Sitecore Http Request handler (HttpModule).
The scope of the value is page and it is stored in the Items variable "SC_CURRENT_LAYOUT".
The following example builds a special layout if the user is a special user.
public void BuildVIPLayout(string user) {
if (user == "VIP") {
State.CurrentLayout = "VIP layout";
State.AddRenderings.Add("VIPRendering");
}
}
State Class | Sitecore.Configuration Namespace | CurrentLayoutChanged