3

This is my first time with Dynamic Placeholders and having a hard time getting started.

I have installed the package from here
https://marketplace.sitecore.net/en/Modules/I/Integrated_Dynamic_Placeholders.aspx

and trying to render a component as

@Html.Sitecore().DynamicPlaceholder("section")

When browsing the page in preview mode, the error is

    Sitecore.Mvc.Helpers.SitecoreHelper' does not contain a definition for 'DynamicPlaceholder and   
  no extension method 'DynamicPlaceholder' accepting a first argument of    
  type 'Sitecore.Mvc.Helpers.SitecoreHelper' could be found (are you missing 
   a using directive or an assembly reference?)

'

If I just say, @Html.Sitecore().Placeholder("section"), it works fine.

Using Sitecore 8.2 with MVC

SOLUTION:

Patrick Barron's answer worked. There are two parts to it:

In the /Views/web.config include the namespace

<add namespace="SitecoreExperienced.SitecoreControls" />

, and in the content editor, when adding the controls, append "_scexp1" to the placeholder name. eg:

1st Rendering: widgets
Placeholder key : section

2nd Rendering: banner
Placeholders : section_scexp1

3rd Rendering: banner
Placeholders : section_scexp2

2
  • Have you checked to make sure the additional assemblies from the marketplace package are in your Sitecore bin folder? And just as a note - this hasn't been updated for 8.2.
    – mservais
    Dec 20, 2016 at 15:33
  • Be aware with this module that since the placeholder keys are generated dynamically at runtime, if you added a new banner component between 1st and 2nd it have the key section_scexp1 and the net effect is that you cannot add any new placeholder "in between". It's a bit confusing to the content editors and means manually moving components at best.
    – jammykam
    Dec 21, 2016 at 19:44

1 Answer 1

3

From the error message, it sounds like the DLL for the Dynamic Placeholder isn't a known reference for your views. You'll want to add the following line to your /Views/Web.config file in your view folder:

<add namespace="SitecoreExperienced.SitecoreControls" />

To should look something like:

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="Sitecore.Globalization"/>
    <add namespace="Sitecore.Mvc" />
    <add namespace="Sitecore.Mvc.Presentation" />
    <add namespace="System.Web.Routing" />
    <add namespace="SitecoreExperienced.SitecoreControls" />
  </namespaces>
</pages>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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