The script is meant to create a navigation menu. It is a modified version of the navigation script that comes with the initial umbraco install. For the life of me, I just cannot seem to get it to start from the particular node I want it to.
If anyone has any ideas, I would be very appreciative. Thank you for looking.
Hi Fuji, thanks so much for spending your time for me.
I gave that a try and still the same :(. No output at all.
My content tree looks like follows;
Also as an addition, note that I have found the following code works in that it will loop through with the foreach, but it always starts from the ancestor above the current page...which is not really what I want :(
var parent = @Model.AncestorOrSelf(1);
The output should be the navigation secondary node and children nodes in an unordered list. At least, that is the intention :) Here is some sample code;
Sorry i didnt notice you miss spelll NodeById. Anyways let try doing it this way
@{ var parent = Model.NodeByid(2278); var items = parent.Children;
if(parent.Children.Where("Visible").Count() > 0){ /// here you can check if you have childnodes if they are visible assuming you are using property umbracoNaviHide <ul id="secondaryNav"> @foreach(dynamic nodes in items){ if(nodes.IsFirst()){ <liclass="first"><ahref="#">@nodes.Name</a></li> } else if(nodes.IsLast()){ <liclass="last"><ahref="#">@nodes.Name</a></li> } else{ <li><a href="#">@nodes.Name</a></li> } } </ul> } }
Oh, How embarassing :) Yes, the problem was NodyById! Bad typing :)
I can't believe I spent hours on this one!
Thank you Bo and Fuji, so much appreciate your help, honestly I was almost ready to pack it in and become a sales guy instead :)
Also, I haven't tried it yet Fuju, but your rewritten code is easier to read than mine, I will have a play with it now. I may learn some things.
I am currently editing in a browser because I've never figured out how to easily deploy stuff from visual studio. Perhaps that would have preventedwhat should have been an obvious mistake.
Noob cannot get @Model.NodyById() to work
Hello there, I am a noobie at writing razor scripts and I am struggeling to get the following code to work in Umbraco 4.7.1;
The script is meant to create a navigation menu. It is a modified version of the navigation script that comes with the initial umbraco install. For the life of me, I just cannot seem to get it to start from the particular node I want it to.
If anyone has any ideas, I would be very appreciative. Thank you for looking.
Hi John,
Are you getting any output from the code above?
Can you try changing
And if you dont mind you could show what your structure looks like and what should be the output
//fuji
Hi Fuji, thanks so much for spending your time for me.
I gave that a try and still the same :(. No output at all.
My content tree looks like follows;
Also as an addition, note that I have found the following code works in that it will loop through with the foreach, but it always starts from the ancestor above the current page...which is not really what I want :(
The output should be the navigation secondary node and children nodes in an unordered list. At least, that is the intention :) Here is some sample code;
Thanks again so much for having a look. Im new to it, and Im finding it very frustrating that I can't do this! One would think it is simple :)
Hi John,
Have you tried Model.NodeById() instead of Model.NodyById() ? :-)
Hi John,
Sorry i didnt notice you miss spelll NodeById. Anyways let try doing it this way
Hope this helps
//fuji
Oh, How embarassing :) Yes, the problem was NodyById! Bad typing :)
I can't believe I spent hours on this one!
Thank you Bo and Fuji, so much appreciate your help, honestly I was almost ready to pack it in and become a sales guy instead :)
Also, I haven't tried it yet Fuju, but your rewritten code is easier to read than mine, I will have a play with it now. I may learn some things.
I am currently editing in a browser because I've never figured out how to easily deploy stuff from visual studio. Perhaps that would have preventedwhat should have been an obvious mistake.
Thank you guys.
John
is working on a reply...