2

I am new to Sitecore, and working on my first project, so please forgive any obvious questions here.

I am working on building the project using the Helix architecture, using Habitat as inspiration (but not using project itself as my starting point).

I am getting confused about placeholders. Habitat uses a placeholder called "head" to put metadata onto the page.. I can't find this placeholder as an item anywhere within any sitecore item in the habitat project (unless I am being totally blind).. As I understand, in Sitecore, you define the placeholder in your layout.cshtml file (i.e. @Html.Sitecore().Placeholder("head") ), but you must also create a Placeholder item within Sitecore , whose placeholder Key matches what you defined in the layout.

My metadata rendering didn't appear until I created the "head" Placeholder item in my own project. (I bound this to the "head" placeholder as Habitat does) I am just confused as to why/how the Habitat one works.. is the placeholder defined somewhere else?

My next question is regarding where/how sitecore rocks populates the "Browse" window the lists available placeholders when adding renderings to a layout? I've added new placeholders in sitecore, and defined these in the layout.cshtml file, but they still don't appear.. What am I missing?

Browse window

Cheers, Danny

2

Sitecore placeholder is an object to add the presentation rendering on the predefined positions. In your example "Head" is a placeholder key which works same as ID for a html element so when sitecore resolve the rendering and its position it check the placeholder key assign to that rendering and render content at that key. "Head" key's position is some where in head tag so it basically render meta thing in head section. You don't need to create any placeholder item in Sitecore. But yeah you can create placeholder setting to restrict the placeholder wizard to provide and limited options for any particular placeholder key, for example there only need to add a footer at footer placeholder So you can create placeholder setting to allow on footer rendering for footer placeholder.

With Regards to your second question. Sitecore rocks scan the current selected layouts and renderings for the placeholder key so developer can easily select anyone of them.

Thanks,

| improve this answer | |
1

The dialog lists all the placeholders for the selected layout and for all renderings that were added to the page. It parse Layout and renderings that were added to the page for @Html.Sitecore().Placeholder("placeholder-key") and it shows you in the list.

For example,you have Default Layout on page. Default Layout contains 3 placeholders : header, content and footer. On header placeholder you have a view rendering Header which has 2 placeholders : header-left and header-right.

In your list you will have 5 placeholders: header, content and footer from the layout and header-left and header-right from the Header view-rendering.

| improve this answer | |
  • AHH. turns out folder sync wasn't working, so changes I thought I was making on view were not being copied to web folder.. not sure why folder sync isn't working however. – mp3duck Aug 9 '17 at 13:17

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