It’s a common convenience to allow website visitors to navigate to the next document within a category without resorting to the back button. You might utilize this design paradigm at the bottom of a blog post to encourage your visitors to read another one of your articles. Lucky for us, Umbraco has a built-in extension function for doing just this sort of thing with the Razor syntax.
SiblingContentNavigation
.Headline
property on my Master document type that requires this property on all document types, allowing me to safely reference the property in the partial view. You’ll need to add the Headline
property or change the property value in the view to reflect a property existing on your documents.@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var previousItem = Model.Content.PrecedingSibling();
var nextItem = Model.Content.FollowingSibling();
}
<div class="row" data-equalizer>
<div class="small-6 columns">
@if (previousItem != null)
{
<a href="@previousItem.Url">
<div class="panel" data-equalizer-watch>
<h5 class="text-right">
« Previous
</h5>
<p class="text-right">
@previousItem.GetPropertyValue("headline")
</p>
</div>
</a>
}
</div>
<div class="small-6 columns">
@if (nextItem != null)
{
<a href="@nextItem.Url">
<div class="panel" data-equalizer-watch>
<h5 class="text-left">
Next »
</h5>
<p class="text-left">
@nextItem.GetPropertyValue("headline")
</p>
</div>
</a>
}
</div>
</div>
BlogPost
.@Html.CachedPartial("SiblingContentNavigation", Model.Content, 86400000, cacheByPage: true)