Saturday, November 24, 2018

Placeholder settings and Dynamic placeholder in sitecore


Hi All, welcome back, In this post we will see about placeholders and dynamic placeholders in sitecore 9.

Here you go,


What is placeholder?

  • The placeholder is simply an area of the page to support the user adding controls(components).
  • The placeholder key identifies the placeholder.

Placeholder settings item

  • Placeholder settings items are definition items for placeholder keys.
  • Placeholder settings items controls author permissions in the experience editor.



Advantages of Placeholder settings:

  1. Make placeholder selectable in the experience editor.
  2. Used to restrict adding of components by using allowed controls(restricts user to add specified components in allowed controls)only
  3. easily change the component via experience editor.

 To call a placeholder in sitecore:

             @Html.Sitecore().Placeholder(placeholderkey)


Dynamic placeholder in sitecore 9

  • With dynamic placeholder,you can add the same placeholder name several times.
  • Unique keys are guaranteed across different renderings and within one rendering. 

The DynamicPlaceholder extension method is available in the SitecoreHelper class in the Sitecore.Mvc.Helpers namespace.

The method has a number of overloads:

Syntax:

          DynamicPlaceholder(string placeholderName, int count = 1, int maxCount = 0, int seed = 0)

placeholderName - the name of the placeholder.
count            - specifies how many placeholders Sitecore renders.
maxCount   - the upper limit.
seed             - a number used to calculate a starting value of a generated placeholder key.

Example:

@Html.Sitecore().DynamicPlaceholder("content"/*, optional parameters*/)

I hope now you have an idea about placeholder settings in sitecore. Don't forget to share with your friends .Happy Coding :)

No comments:

Post a Comment

Check the users Logged into the sitecore backend

Hi, Today I'm going to discuss about " how to check the concurrent users logged into the sitecore backend ? ". For this ...