Sitecore: How to use codebehind subtask options?

How to get the values ​​from the “Parameters” field (second screenshot) in the code lock of the subblock?

I understand that I can get / set the rendering parameters (in particular, the subarea) when it is added to the details of the element’s presentation, as described here ( Sitecore 6 - using parameters ).

layout instance parameters

However, I would like to use the parameter field from the layout definition element. In the code for the file definition-related code, I can cast the parent to a sublayer, and this object also has a property .Parameters, however it does not contain the expected values.

layout definition parameters

This is the method Page_Loadin the control code:

protected void Page_Load(object sender, EventArgs e)
{
    var sublayout = ((Sublayout)this.Parent);
    string rawParameters = Attributes["sc_parameters"];
    NameValueCollection parameters =
      Sitecore.Web.WebUtil.ParseUrlParameters(rawParameters); 
      //parameters contains values from "Additional parameters (first screenshot)

      //I do not know the sublayout item id or sublayout path, so how do I get
      //the values from the second screenshot?
}

Doublecheck still does not work, only additional parameters:

Step 1 - Enter parameters

Step 2 - Add sublayout + parameters to presentation

Step 3 - Display parameters on sublayout

Step 4 - Validate result

+5
2

, , . ,

   var sublayout = ((Sublayout)this.Parent);
   //Get all rendering
   var renderings = Sitecore.Context.Item.Visualization.GetRenderings(Sitecore.Context.Device, true);

   //Get the first rendering that matches the current sublayout path
   var sublayoutRendering = renderings.FirstOrDefault(r => r.RenderingItem.InnerItem["Path"] == sublayout.Path);

   if (sublayoutRendering != null)
         Response.Write(sublayoutRendering.RenderingItem.Parameters);

Mark , " "

EDIT: , sitecore, . . , .

+2

:

var sublayout = ((Sublayout)this.Parent);
NameValueCollection nvc = Sitecore.Web.WebUtil.ParseUrlParameters(sublayout.Parameters);

, .

Sitecore, . , Sitecore USA.

+11

All Articles