Layout Documents Should use AMD style JS Injection
Main Layout
Open your Main layout razor view file and perform edits as follows:
#1 Add Analytics Visitor Identification code if it is not already there
@using Sitecore.Mvc.Analytics.Extensions @Html.Sitecore().VisitorIdentification()
See http://stackoverflow.com/questions/30120608/is-html-sitecore-visitoridentification-required-with-sitecore-8-mvc for more details
#2 Update pageWrapper CSS class
Old Code:
<div class="pageWrapper">
New Code:
<div class="page-wrapper">
#3 Load Javascripts using AMD and Require.JS
Remove all Script links from HTML body
Add code
@foreach (var area in new[] { "ScoreCCF", "ScoreBootstrapUI", "<ProjectArea>" }) { <script src="@Url.Content("~/Areas/" + area + "/js/require.config.js")" type="text/javascript"></script> } <script src="@Url.Content("~/Areas/ScoreCCF/js/Vendor/require.js")" data-main="/Areas/<ProjectArea>/js/main.js" type="text/javascript"></script>
Snippet
Now we are done with Main layout and can do something similar to Snippet. Open Snippet layout and follow steps below.
#1 Add code for component name
In SCORE 2.0 we added new component Macro that also uses this layout. Lets add code below to generate correct Component name.
@using Score.Data.ViewModels.Snippets @{ var name = SnippetContainerModel.SnippetOrMacro(Model.PageItem); }
#2 Update H1
new code:
<h1>Content @name</h1>
#3 Update CSS class in main DIV
find <div class="pageWrapper snippet-content">
and replace it with code below
<div class="page-wrapper snippet-content">
#4 Use AMD to load JSs similar to what we did in Main
Remove all Script links from HTML body
Add code
@foreach (var area in new[] { "ScoreCCF", "ScoreBootstrapUI", "<ProjectArea>" }) { <script src="@Url.Content("~/Areas/" + area + "/js/require.config.js")" type="text/javascript"></script> } <script src="@Url.Content("~/Areas/ScoreCCF/js/Vendor/require.js")" data-main="/Areas/<ProjectArea>/js/main.js" type="text/javascript"></script>