I really need some help with razor. I am fine with XSLT but cannot figure out how to put in an if statement in my menu. I have a url picker with the alias 'pageNameInMenu' I would like the user to be able to select content or an external url for any given page. I have been able to fdo this for my XSLT menu's but can't figure it out in razor. I'm using Umbraco Version 6.1.5 and this is my menu script. Any help would be appreciated even pointing me to a tutorial would be very helpful.
Thanks
Natasha
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ @*Get the root of the website *@ var root = Model.AncestorOrSelf(1); }
Since you want to be able to select content or an external url for any given page, I think that you should have a look on uComponents and their URL Picker.
In the documentation for the URL Picker there is a Razor example. I hope this can help you to what you want.
Thank you both for your help, but where exactly do I put this code. I have tried it under the for each statement, but that throws an error. What it shoulde be is if the url has a conent or external link the select that else use the Li I hope that makes sense?
Fuji your code works beautifully for the 1st level nav but it returning nothing for the 2nd level anyone give me any pointers on what I'm doing wrong? Code below:
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
@*Get the root of the website *@
var root = Model.AncestorOrSelf(1);
}
<ul id="accordion">
@foreach (var page in root.Children.Where("Visible"))
If statement for url picker on accordion menu
Hi There
I really need some help with razor. I am fine with XSLT but cannot figure out how to put in an if statement in my menu. I have a url picker with the alias 'pageNameInMenu' I would like the user to be able to select content or an external url for any given page. I have been able to fdo this for my XSLT menu's but can't figure it out in razor. I'm using Umbraco Version 6.1.5 and this is my menu script. Any help would be appreciated even pointing me to a tutorial would be very helpful.
Thanks
Natasha
Hi Natasha,
Am not sure where you are using the urlPicker here but as a guess i would try somethin like
Hi Natasha,
Since you want to be able to select content or an external url for any given page, I think that you should have a look on uComponents and their URL Picker.
In the documentation for the URL Picker there is a Razor example. I hope this can help you to what you want.
/Dennis
Thank you both for your help, but where exactly do I put this code. I have tried it under the for each statement, but that throws an error. What it shoulde be is if the url has a conent or external link the select that else use the Li I hope that makes sense?
Thanks again.
Fuji your code works beautifully for the 1st level nav but it returning nothing for the 2nd level anyone give me any pointers on what I'm doing wrong? Code below:
You mean in the grandchildpage ?
If so you need to check in the grandchildpage as well not in Model.
Got it working
Thanks so much you're a super star
is working on a reply...