Oct 26, 2012 at 8:47 AM
Edited Oct 26, 2012 at 9:05 AM
Thanks for your help. It's a custom field I've added to MenuPart. I want to be able to set a menu Active when the path contains a given string. So that field let me enter the path I want the menu to match. So I will for example set "/Products/"
as value. Then in MenuItem.cshtml, I want to add the class "active" to the menu when the path contains /Products/.
I have tried with and without .Content at the beginning. If I include .Content at the beginning, I get the mentioned exception. If I don't include it, I don't get any exception, but the value is always null. What is strange is that shape tracing tool show
me the value correctly (with .Content at the beginning). So I suppose I'm doing something wrong but can't find what.
So to resume my problem:
- I've added a custom text field (say MatchRoute) in MenuPart.
- In admin, I then have that additional field when editing menu items.
- I've copied MenuItem.cshtml file from Szmyd.Orchard.Modules.Menu\Views folder to my template View folder.
- I customized MenuItem.chtml to match my needs.
- I can't find how I can read the value set to MatchRoute field from the view.
Maybe there is a better way of doing what I try. I just want to be able to indicate that a menu should have the classe "active" when the path contains a given string. That string has to be editable in admin.