but i have 4 different classes i.e li1,li2,li3,li4....and i need first child should get class li1 and second child li2 respectively ...i tried alot but can't get the answer please help me!
i want to apply a class for first 4 pages like li1 for page 1 and li2 for page 2 respectively ...rest of the 2 pages must have diffierent class and first for page 5 and last for page 6...
i have tried the following code
@{ var homePage =CurrentPage.AncestorOrSelf(1); var menuItems = homePage.Children.Where("Visible"); }
@foreach(var item in menuItems.ToContentSet()) { var position =string.Format("li{0}", item.Position()+1); <li class="@position"><a href="@item.Url">@item.Name</a></li> }
Navigation with different classes
Hii all,
I am Ravindra...
I have a Master page with 4 child pages..i used a navigation in my master..i.e
@{
var homePage = CurrentPage.AncestorsOrSelf(1).First();
var menuItems = homePage.Children.Where("UmbracoNaviHide == false");
}
@foreach(var item in menuItems){
<li class="li2"><a href="@item.Url">@item.Name</a></li>
}
but i have 4 different classes i.e li1,li2,li3,li4....and i need first child should get class li1 and second child li2 respectively ...i tried alot but can't get the answer please help me!
Regards...
Ravindra
Hi Ravindra,
How about this:
Jeavon
Thank u very much jeavon!
let me check it
Regards...
Ravindra
Thank you very much jeavon!
it's working!
Regards,
Ravindra....
HIii...i have 6 pages in my site...
i want to apply a class for first 4 pages like li1 for page 1 and li2 for page 2 respectively ...rest of the 2 pages must have diffierent class and first for page 5 and last for page 6...
i have tried the following code
please help me!
Regards
Ravindra
Something like this (change to your needs)
Thanks jeavon!
its working
Regards,
Ravindra..
is working on a reply...