Create dynamic menu with page sections

Since Sitecore Habitat has been released I was looking for a Helix based solution which can be use for Greenfield project. Once again – Habitat is only an example of project implementing Helix architecture.  I looked at Helixbase and I tried to  implement one of bootstrap free template sites to evaluate it as a candidate.

agency

I thought it would be nice to add automatically to the menu new section item each time that editor is adding a new one and create an anchor to that section.

 

@model RenderingModel
@{
 var currentItem = Sitecore.Context.Item;
 RenderingReference[] myRenderings = currentItem.Visualization.GetRenderings(Sitecore.Context.Device, true);
 var layoutField = new LayoutField(currentItem);
 LayoutDefinition layoutDef = LayoutDefinition.Parse(layoutField.Value);
 DeviceDefinition deviceDef = layoutDef.GetDevice(Sitecore.Context.Device.ID.ToString());
 string sectionId = string.Empty;

}
<!-- Collect the nav links, forms, and other content for toggling -->

<!-- /.navbar-collapse -->

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s