Developer forum

Forum » Templates » Razor navigation peer review

Razor navigation peer review

Martin Grønbekk Moen
Reply

I wanted to have Razor navigation, and I could not find any example code for it, so I created my own.
Would be nice to have some peer review on the code to see if this is a approach worth taking to razor navigation.

Feel free to comment on the code.


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Martin

Looks great! You are not chekking "PageHidden" which can be true and the page should not appear in navigation. Also goes for PageActiveFrom and PageActiveTo, which is the publication period.

Also if you are using personalization, and visibility options for different devices, the result will not be as expected.

BR Nicolai

 
Martin Grønbekk Moen
Reply

Thanks for input, I have updated the code.

 
Sten Hougaard
Reply

Hi Martin,

Thank you for sharing! 

If I were to use this helper function how would I use it?

Could you perhaps add an example code snippet showing how to use th helper function?

/Sten Hougaard

Twitter: @netsi1964

#hireMe - I am looking for a new job, so if you need an experienced front-end developer, please contact me: netsi1964@gmail.com

 
Nicolai Høeg Pedersen
Reply

@Martin: Nice, thanks for sharing.

@Sten: He shows that calling @RenderNavigation(collection, PageID) - that is calling the navigation helper. You then just need to find the right pages to render.

 
Martin Grønbekk Moen
Reply

Or just dont enter anything, and it will by default show whole menu from root and down within the area you are in.
I have an example in my first post on how I call the helper. Hope you can use it.

 

You must be logged in to post in the forum