A flexible table of contents for site footer. Razor Umbraco 6.
@* Umbraco 6 *@
@* Will confilict with bootstrap, change row class *@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var startNodeID = CurrentPage.AncestorOrSelf().Id;
int columnno = 2; @* Add the amount of columns needed *@
int count = 0;
int counthold = count;
}
@if (startNodeID != null)
{
var startNode = Umbraco.Content(startNodeID);
if (startNode.Children.Where("Visible").Count() > 0)
{
<div class="Table">
@foreach (var page in startNode.Children.Where("Visible"))
{
if(count%columnno == 0){
@:<div class="Row">
}
<div class="Cell">
<a href="@page.Url">
<p>
@if(@page.HasValue("PageTitle")){
@page.PageTitle
count++;
}else{
@page.Name
count++;
}
</p>
</a>
</div>
if(count%columnno == 0){
@:</div>
}
}
@if(count%columnno != 0){
@:</div>
}
</div>
}
}
@* Associated CSS - Put in Stylesheet *@
<style type="text/css">
.Table{
display: table;
}
.Row{
display: table-row;
}
.Cell{
display: table-cell;
border: solid;
border-width: thin;
padding-left: 5px;
padding-right: 5px;
}
</style>
@* This is the code if home button needs adding at the beginning. *@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var startNodeID = CurrentPage.AncestorOrSelf().Id;
int columnno = 2;
int count = 0;
int counthold = count;
}
@if (startNodeID != null)
{
var startNode = Umbraco.Content(startNodeID);
if (startNode.Children.Where("Visible").Count() > 0)
{
<div class="Table">
@Html.Raw("<div class='Row'><div class='cell'><a href='/'><p>Home</p></a></div>")
@{
count++;
}
@foreach (var page in startNode.Children.Where("Visible"))
{
if(count%columnno == 0 && count!=0){
@:<div class="Row">
}
<div class="Cell">
<a href="@page.Url">
<p>
@if(@page.HasValue("PageTitle")){
@page.PageTitle
count++;
}else{
@page.Name
count++;
}
</p>
</a>
</div>
if(count%columnno == 0){
@:</div>
}
}
@if(count%columnno != 0){
@:</div>
}
</div>
}
}