1

I want to give a token $name in the parameter value of a rendering which is present in the standard value of a template so that when I create new item of this template, the item should have the rendering and parameter of this rendering should be same as the item name.

Example:

When I create a new item from product template, the parameter value of the rendering header should be same as the item name.

I tried this by giving the token $name in the parameter value of the rendering in the standard value but I think this is not supported by sitecore.

Is there any other way to do this.

Please see the screenshot of what i tried

  • Why do you want your page item name to be a rendering parameter? – Gatogordo Dec 28 '17 at 12:09
  • i have enabled caching for this rendering and i have selected vary by param.i need different parameter for each item. – Dheeraj p Dec 28 '17 at 13:01
  • @Dheerajp instead of using vary by param, you could use vary by data – Hishaam Namooya Dec 28 '17 at 13:06
  • 1
    "When I create a new item from product template" - rendering parameters are stored as part of the rendering and not created when you create an item from a template. Tokens will not be expanded since it is not part of the template. – jammykam Dec 28 '17 at 15:55
  • @Hishaam "vary by data" isn't working in my case . "Vary by param" works but difficult to update parameter value for multiple items. – Dheeraj p Dec 29 '17 at 14:00
1

This is a bit of a hack (and can potentially cause some damage). The pipeline that replaces the values is the expandInitialFieldValue. In it is the Sitecore.Pipelines.ExpandInitialFieldValue.ReplaceVariables processor which essentially replaces the known variables on all the fields. The keyword is "All" the fields...so why doesn't it replaces your example above. The culprit is that when you are updating the parameters in the dialog, the "$" dollar sign gets encoded to "%2524" thus the default replacer is unable to update it.

To make this work, assuming you've updated the parameters already as you specified above:

  1. Go to your template's _Standard Values item in the Content Editor.

  2. In the View ribbon tab, check Raw Values and Standard Fields to see the Renderings field.

  3. Copy the field's XML value and paste it on Notepad.

  4. Find the encoded dollar sign (%2524) and replace it with the actual dollar sign ($).

  5. Copy and paste the updated XML back to the field. You should still be able to open the Presentation details as normal but it may encode the dollar sign again...so just check it.

Now, when you create a new item based on that template, the item's name should now be the value of the parameter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.