Skip to content

Instantly share code, notes, and snippets.

@herskinduk
Last active April 29, 2016 08:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herskinduk/f04e9354922fa1068726 to your computer and use it in GitHub Desktop.
Save herskinduk/f04e9354922fa1068726 to your computer and use it in GitHub Desktop.
Sitecore MVC inside-out layout
@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc
@model RenderingModel
@{
Layout = null;
Sitecore.Context.Items["twitter:title"] = Model.Item["title"]
Sitecore.Context.Items["twitter:description"] = Model.Item["description"]
}
<h1>@Html.Sitecore().Field("title")</h1>
@Html.Sitecore().Field("text")
@using Sitecore.Mvc
@{
Layout = "OuterLayout.cshtml";
}
<div>
@Html.Sitecore().Placeholder("main")
</div>
@using Sitecore.Mvc
@using Sitecore.Mvc.Analytics.Extensions
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>@Html.Sitecore().Field("title", new { DisableWebEdit = true })</title>
@Html.Sitecore().VisitorIdentification()
@if (Sitecore.Context.Items["twitter:title"] != null && Sitecore.Context.Items["twitter:description"] != null)
{
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="@Sitecore.Context.Items["twitter:title"]" />
<meta name="twitter:description" content="@Sitecore.Context.Items["twitter:description"]" />
}
</head>
<body>
@RenderBody()
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment