1
votes

So I have a layout view within Sitecore Mvc, this view contained a Controller Rendering that pulls in a header and footer navigation. Example:

@Html.Sitecore().Rendering("/sitecore/layout/renderings/some_rendering")

This specifies a Controller Rendering I've defined in Sitecore. This works great, except when I'm in the experience editor. It doesn't give me the ability to select this rendering. If I create a Placeholder and then define these navigation elements to this placeholder dynamically via Sitecore, then I can, but these navigational elements exist on every page of this layout, so I would like them statically placed instead of using a Placeholder, but I would still like the user to be able to select the navigation element in the experience editor (so I can create custom command to interact with this navigation, such as creating new links, etc).

Does anyone have an idea that will help me achieve this?

2

2 Answers

1
votes

Use Edit Frame for that and create Custom Edit Frame Button for operations like adding new element to the navigation.

And remember to pass Datarsource ID or Path as a second parameter to the Html.Sitecore().Rendering() method:

@Html.Sitecore().Rendering("/sitecore/layout/renderings/some_rendering", new { DataSource = "{some-id-or-path}" })

Here is set of blog posts which can help you to understand how Edit Frames work and how to add them in Sitecore MVC solution:

  1. https://visionsincode.wordpress.com/2015/01/08/how-to-use-editframe-in-sitecore-mvc/
  2. https://www.cmsbestpractices.com/how-to-properly-use-sitecore-edit-frames/
  3. https://briancaos.wordpress.com/2011/11/28/using-sitecore-editframe-in-pageedit/

You won't be able to remove the component or move it around the page (yeah, it's statically bound to one place on your layout), but you will be able to edit it's properties and datasource.

0
votes

You can try to use GlassMapper views and statically inherit the view from the GlassView. Then you'll be able to use Editable method to render the field.

But the consideration you need to take is that you'll not be able to set a datasource to the component from the page editor or content editor.

Instead of injecting the rendering through the Rendering method you should be able to use standart MVC RenderPartial.

I've used this approach on one of the projects I've been on and it worked.