asp.net mvc - Using a single Sitecore view rendering multiple times on the same page with different data -


i new developing sitecore using mvc. have page layout looks this:

<!doctype html> <html lang="en"> <head>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     @html.sitecore().placeholder("head-meta-content") </head>  <body>     <div class="willow-page">         @html.sitecore().placeholder("body-content")     </div> </body> </html> 

and have following renderings.

global alert:

@using sitecore.mvc; @model sitecore.mvc.presentation.renderingmodel  <section class="global-alert" role="alert">     <button class="global- alert__close">@html.sitecore().field("button-text", model.item) </button>     <h1 class="global- alert__heading">@html.sitecore().field("heading-text", model.item)</h1>     <div class="global-alert__content">         @html.sitecore().placeholder("global-alert-content")     </div> </section> 

styling context:

@using sitecore.mvc; @model sitecore.mvc.presentation.renderingmodel  <div class="styling-context">     @html.sitecore().field("content", model.item)     <!-- content field should rich text field --> </div> 

what trying accomplish/understand this. when creating page using layout , 2 renderings, i'd add global alert body-content place holder on layout , add styling context global-alert-content place holder. i'd add styling context body-content place holder well. this:

sitecore device editor display controls

then when viewing page content tab in sitecore, i'd see section rich text field global alert styling context & body styling context. can't seem figure out how setup data accomplish this.

i've tried setup following data templates.

global alert template - builder

global alert template - builder

global alert template - content

global alert template - content

notice _stylingcontext in base template area above.

styling context - builder

styling context - builder

blank page - page template

blank page - page template

note inherited templates above.

the global alert template pulling in styling context template, & page template pulling separate styling context template, think there'd 2 on page. there isn't though.

this normal behavior of sitecore. reason because same template being referenced in base template. so, when rendering item, sitecore see template has been rendered , not render again.

if template has base template x , x has base template y, not possible have template have y base template also.

a => x x => y means => y 

to allow 2 rich text appear, can following:

  1. create base styling context

enter image description here

  1. on template styling context, add content field of type rich text in builder tab , in content tab, add base styling template.

enter image description here

  1. on global alert template, in content tab, add styling context template.

enter image description here

  1. on blank page template, add global alert , not styling context.

enter image description here

now if see on standard values of blank page template, see 2 rich text fields same field name within same section:

enter image description here


Comments