Umbraco & Razor: If CurrentPage/Model is a Child, condition -
My navigation / node structure is as follows:
Home
- About Us
- Our services ----- Finance ----- Insurance -
Lies my current code through nodes and lists them in one. When there are children on 'Current Page', children are included in the menu.
The problem with this loop is that when a child (finance or insurance) is the 'current page', then 'if' condition fails in 'our services' node because currently the child is now on the page Not so, therefore 'finance' and 'insurance' will now remain in the menu.
I want to 'if', '' I have to add ''
gt; The code given below
@ourch (@nantpage on var page. Unstourself (1) children.) {& Lt; Li class = "menu itts @ (page.instore and (current page)?" Selected ": blank) & gt; & Lt; A href = "@ page.Url" & gt; @ PageName Testing & lt; / A & gt; & Lt; / Li & gt; {(Current page) • "selected" child ("current page"). "Selected page child". (Count)> (foreach (various child pages in page. Children) {
-
The first foreach must be from your home. ( Do you have level 1 level?)
-
If there is no need to check if there is no child
Do you want only 2 levels of menus? If so, then like this:
& lt; ul & gt; @FrenchTech (Current page in current page. UnstourselfAlex (1).) {{Lc; li class = "MenuItems @ (p.ID == current page.id?") Selected ":" "") & Gt; & lt; a href = "@ page.Url" & gt; @ PageName Test & lt; / a & gt; & lt; / li & gt; @if (CurrentPage.Id == page.Id · CurrentPage.Parent.Id ==Page.id) {foreach (different child page in page). {& Lt; Li class = "menu item menu pulse @ @ (childPage.Id ==) current page.id?" Selected ":" ")" & gt; & Lt; A href = "@ childpage.Url" gt; @ ChildPage.Name & lt; / A & gt; & Lt; / Li & gt; }} & Lt; / Ul & gt;
Comments
Post a Comment