I'm trying to implemente a breadcrumb with the following code :
<umbraco:Macro runat="server" language="cshtml"> @inherits umbraco.MacroEngines.DynamicNodeContext @foreach(var level in @Model.Ancestors().Where("Visible")) { » <---- Does NOT work <a href="@level.Url">@level.Name</a> } » <---- Works fine @Model.Name </umbraco:Macro>
My second » works as intended but the first one fails.
Could anyone explain why? By the way, i'm used to work in vb so this c-stuff is new to me :)
ouch, yes - reminds me, the <text> tag does not work in razor direct in a template ( http://umbraco.codeplex.com/workitem/30098 )... you will need to make a macro of your code to make it work. Might be other workarounds also, but I would recommend a separate macro.
Error with formatting
Hi
I'm trying to implemente a breadcrumb with the following code :
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@foreach(var level in @Model.Ancestors().Where("Visible"))
{
» <---- Does NOT work
<a href="@level.Url">@level.Name</a>
}
» <---- Works fine
@Model.Name
</umbraco:Macro>
My second » works as intended but the first one fails.
Could anyone explain why? By the way, i'm used to work in vb so this c-stuff is new to me :)
/ Ulrik
Whoops - something dissapeared when I posted.
» should be »
Hi, in these cases it's usually good to wrap the html in <text> tags,
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@foreach(var level in @Model.Ancestors().Where("Visible"))
{
<text> » </text> <---- Add <text>
<a href="@level.Url">@level.Name</a>
}
»
@Model.Name
</umbraco:Macro>
Thanks for the response Jonas. Sounds logical :)
Tried it but got this error :
The 'text' property of 'umbraco.presentation.templateControls.Macro' cannot be declared as an inner property, it must be declared as an attribute.
ouch, yes - reminds me, the <text> tag does not work in razor direct in a template ( http://umbraco.codeplex.com/workitem/30098 )... you will need to make a macro of your code to make it work. Might be other workarounds also, but I would recommend a separate macro.
Aaaah. Great - I'll do that.
Thanks again
Another alternative : add the @: before the markup instead of <text>. Shorter syntax, and should work in fine template too.
Cool. Worked perfectly - so thats what I'm using now :)
is working on a reply...