Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hey guys...
I have a sitetree looking like this:
Then i'ev created a razor menu like this:
@inherits umbraco.MacroEngines.DynamicNodeContext
@foreach (var item in @Model.Children.Where("Visible"))
{
var cssClass = "";
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString());
if(item.isActive) { cssClass = "active"; }
if(item.isFirst()) { cssClass += " first"; }
if(item.isLast()) { cssClass += " last";}
if(selected >= 0) { cssClass += " selected";}
var liClass = "";
if(cssClass != string.Empty) {
liClass = string.Format("class\"{0}\"", cssClass.Trim());
}
<[email protected](liClass)>
<a href="@item.Url">@item.Name</a>
</li>
----------------------
However, this outputs the children of the item "Solution" - I want the menu to output: SolutionAmericasLeasingTechnics
So only the four items that it in the Content Tree ? - How do i do that?
hii nicky
i think it will be better to put your content under a main node ( lets say home )
content
-- home
---- sulotion
---- americas
etc...
then you can use the Navigation template when you create a scripting file...
@{
var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level);
var ulClass = String.IsNullOrEmpty(Parameter.UlClass) ? "" : String.Format(" class=\"{0}\"", Parameter.UlClass);
var parent = @Model.AncestorOrSelf(level);
if (parent != null) {
@foreach (var item in parent.Children.Where("Visible")) {
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : "";
@item.Name
Ahh, of course :) Thx
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Razor menu for my top level ?
Hey guys...
I have a sitetree looking like this:
Then i'ev created a razor menu like this:
@inherits umbraco.MacroEngines.DynamicNodeContext
@foreach (var item in @Model.Children.Where("Visible"))
{
var cssClass = "";
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString());
if(item.isActive) { cssClass = "active"; }
if(item.isFirst()) { cssClass += " first"; }
if(item.isLast()) { cssClass += " last";}
if(selected >= 0) { cssClass += " selected";}
var liClass = "";
if(cssClass != string.Empty) {
liClass = string.Format("class\"{0}\"", cssClass.Trim());
}
<[email protected](liClass)>
<a href="@item.Url">@item.Name</a>
</li>
}
----------------------
However, this outputs the children of the item "Solution" - I want the menu to output:
Solution
Americas
Leasing
Technics
So only the four items that it in the Content Tree ? - How do i do that?
hii nicky
i think it will be better to put your content under a main node ( lets say home )
content
-- home
---- sulotion
---- americas
etc...
then you can use the Navigation template when you create a scripting file...
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level);
var ulClass = String.IsNullOrEmpty(Parameter.UlClass) ? "" : String.Format(" class=\"{0}\"", Parameter.UlClass);
var parent = @Model.AncestorOrSelf(level);
if (parent != null) {
@foreach (var item in parent.Children.Where("Visible")) {
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : "";
@item.Name
}
}
}
Ahh, of course :) Thx
is working on a reply...