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
How Can I read level of current node? So if node level is 1, I don't display some info.
Thank you
.Level works, something like this:
@{ var rootNode = Model.AncestorOrSelf(1); foreach (var node in rootNode.Descendants()) { if(node.Level == 2) { <p>@node.Name</p> } else { <p>@node.CreateDate</p> } } }
Oh just noticed that you wanted the current node, that's just:
Model.Level
Good...works..
<umbraco:Macro runat="server" language="cshtml">@inherits umbraco.MacroEngines.DynamicNodeContext @if (Model.Level>1) { <ul> @foreach(var level in @Model.Ancestors().Where("Visible")) { <li><a href="@level.Url">@level.Name</a> > </li> } <li><b>@Model.Name</b></li></ul> } </umbraco:Macro>
Other question: Which is the declaration of vars in upper macro? I try with var livello = @Model.Level but I've error that "livello is out of scope".
I don't know what you want to do, but if you create the livello variable inside the foreach then you can't access it outside of the foreach..
I declare var before @if. Then I wish to use it into if condition.
This does not work?
var livello = 1; @if (Model.Level > livello) { <ul> @foreach(var level in @Model.Ancestors().Where("Visible")) { <li><a href="@level.Url">@level.Name</a> > </li> } <li><b>@Model.Name</b></li> </ul> }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to read level of node?
How Can I read level of current node? So if node level is 1, I don't display some info.
Thank you
.Level works, something like this:
Oh just noticed that you wanted the current node, that's just:
Good...works..
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@if (Model.Level>1) {
<ul>
@foreach(var level in @Model.Ancestors().Where("Visible"))
{
<li><a href="@level.Url">@level.Name</a> > </li>
}
<li><b>@Model.Name</b></li>
</ul>
}
</umbraco:Macro>
Other question: Which is the declaration of vars in upper macro? I try with var livello = @Model.Level but I've error that "livello is out of scope".
I don't know what you want to do, but if you create the livello variable inside the foreach then you can't access it outside of the foreach..
I declare var before @if. Then I wish to use it into if condition.
This does not work?
is working on a reply...