Showing Links in Footer and not in Main Menu
I have the general site with the following in the Main Menu at the top of the site:
Home | About | Contact | etc. (You get the point).
In my footer I want to have links to the Privacy Policy, Terms of Use, Sitemap that I don't want showing up in the top menu.
I want to use the menu control at the footer level, but i have the privacy policy and other pages "do not show in navigation" checked. I don't want to put them in a page group because then the URL looks like /other/privacy-policy. I realize I could just put in a content block and manually type out the links, however once I hand this off the end-user won't know how to update that.
What's the cleanest approach to have 2 separate menus?
Hi Kerri,
The way we have done it is by simply creating a user control, and getting the pages we need via the fluent api in the page load event of the control and binding it to a repeater. We then drag this onto our master pages instead of exposing it as a control to be used by content editors, but i am sure if you wanted to that could be done quite easily.
Like i said we load in the page_load, we grab the urls in the Data Bound event (i am sure this could be cleaner but it works) and then do some last minute adding of classes to the last item for some additional formatting on the pre render (you may not need this).
Some code below:
<
asp:Repeater
ID
=
"rptLinks"
runat
=
"server"
OnItemDataBound
=
"rptLinks_OnItemDataBound"
OnPreRender
=
"rptLinks_OnPreRender"
>
<
HeaderTemplate
>
<
asp:Literal
ID
=
"litHeader"
runat
=
"server"
Text="<ul>" />
</
HeaderTemplate
>
<
ItemTemplate
>
<
asp:Literal
ID
=
"litPrefix"
runat
=
"server"
Text="<li>"/><
asp:HyperLink
ID
=
"hlnkLink"
runat
=
"server"
/></
li
>
</
ItemTemplate
>
<
FooterTemplate
>
</
ul
>
</
FooterTemplate
>
</
asp:Repeater
>
protected void Page_Load(object sender, EventArgs e)
var pageIds = new List<
string
>();
pageIds.Add("ee38f4c6-8f48-4743-8f5f-04a203d77b4b");
pageIds.Add("a3c9876a-fc04-4ecb-802b-54586d496c8a");
pageIds.Add("596806e8-b4ac-41f3-a114-6f746236db5c");
var pages = from p in App.WorkWith().Pages().Get().ToList()
where pageIds.Contains(p.Id.ToString())
orderby p.Ordinal
select p;
rptLinks.DataSource = pages;
rptLinks.DataBind();
public void rptLinks_OnItemDataBound(object sender, RepeaterItemEventArgs e)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
var page = e.Item.DataItem as PageNode;
var link = e.Item.FindControl("hlnkLink") as HyperLink;
link.Text = page.Title;
link.NavigateUrl = page.GetFullUrl();
public void rptLinks_OnPreRender(object sender, EventArgs e)
var lastItem = rptLinks.Items[rptLinks.Items.Count - 1];
((Literal)lastItem.FindControl("litPrefix")).Text = "<
li
class=\"last\">";
Thank you!
Hi Kerri,
What we do is create a dummy page (standard aspx) in our project for development, in that page we use it to grab IDs (Pages, Content Items etc), so for pages we would just to the following in the page_load event of our dummy page:
var pages = App.WorkWith().Pages().Get().ToList();
foreach (var page in pages)
Response.Write("Page: " + page.Title + " ID: " + page.Id.ToString() + "<
br
/>");