View priority help

Topics: Troubleshooting
Feb 14, 2013 at 3:03 PM
Hello all,

I am hoping for some help on a rather strange issue I'm having.

I am using the Onestop.Navigation module, and my scenario concerns the MenuItem.cshtml view in the Views folder. Namely, it doesn't seem to be used!

Instead, for some reason, the menu items are rendered using the Core\Shapes\Views\MenuItem.cshtml view. I have verified this by adding HTML comments to both views.

Also, if I temporarily remove the view from Core\Shapes\Views, the item is rendered using the Onestop view. The obvious conclusion is that the Core view is considered higher priority, but this seems to conflict with the Orchard norm.

This is the first time I have come across this issue, and it has me baffled. Any ideas?

As a fall back, some idea on where to look to start tracking down how Orchard selects the correct view would be great.

Cheers
Developer
Feb 14, 2013 at 3:17 PM
Can you verify that Onestop.Navigation has a reference to Orchard.Core?
I would also be curious what happens if you copy that view to your theme's Views folder.
Feb 14, 2013 at 3:26 PM
Hi,

Thanks for the fast response.

I can confirm that Onestop.Navigation does have a reference to Orchard.Core.

If I copy the view into the theme's View folder, the menu item is rendered from the Theme view, as opposed to the Core view. It's all somewhat mysterious.

Cheers
Developer
Feb 14, 2013 at 3:30 PM
That is strange, yes, because the view from the module that takes a dependency on another module should take precedence. Views from a theme take precedence over all modules. I don't know what this is causing it. Can you reproduce this issue when you create a new module and try to override the view of another module?
Feb 14, 2013 at 3:32 PM
Wait a sec, I think I misunderstood you, do you mean a reference in the Module manifest, or an assembly reference?
Developer
Feb 14, 2013 at 3:36 PM
I meant Project reference, but perhaps it should be a reference from the manifest as well. Or just the manifest, I can't recall. Try it :)
Feb 14, 2013 at 3:37 PM
Some more info:

Setting a priority of 1 in the Core\Navigation\Module.txt and a priority of 2 in the Onestop.Navigation\Module.txt makes the Onestop view render, so it seems like it is something to do with priority.

I have verified that a dependency to Core\Navigation is present in the Onestop.Navigation\Module.txt file.

Thanks for the assistance.
Feb 14, 2013 at 3:45 PM
Turns out I can just set a priority of 2 in Onestop.Navigation, and leave Core untouched, which solves my issue. I'm going to use this as a workaround for now.

Thanks again.