﻿using System;
using Composite.Core.Xml;
using Composite.Core.PageTemplates;
using Composite.Plugins.PageTemplates.MasterPages;
using Composite.Functions;
using System.Collections.Generic;

public partial class MyPageTemplate : MasterPagePageTemplate
{
    public override Guid TemplateId
    {
        get { return new Guid("25de2e26-ab15-4490-8501-b3e8dcb90822"); }
    }

    [Placeholder(Id = "content", Title = "Main Content", IsDefault = true)]
    public XhtmlDocument Content { get; set; }

    public XhtmlDocument distributedMenu { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        distributedMenu = FunctionFacade.Execute<XhtmlDocument>(
            FunctionFacade.GetFunction("Composite.Navigation.Distributed"),
            new Dictionary<string, object>() {
                { "Level", 1 }, { "ShowParent", false }, 
				{ "ShowChildPages", true }, { "Expand", false }, 
				{"NavigationId",  "NavigationSideBar"} });

        // removing the class attribute from the level menu's elements
        foreach (var item in distributedMenu.Descendants())
        {
            item.SetAttributeValue("class", null);
        }
    }
}