This project is read-only.

How to use Parts.MenuWidget-MenuWidget?

Topics: Writing themes
Dec 28, 2013 at 6:58 AM
Edited Dec 28, 2013 at 6:59 AM
I ran across the following explanation on StackOverflow:
Templates for Menu and MenuItem are Menu.cshtml and MenuItem.cshtml. You can start by copying those files from /Core/Shapes/Views/ directory to your theme directory. You can modify them as you wish afterwards.

This will, actually modify all your menus on the site. If you want it to be specifically for your widget (Parts.MenuWidget-MenuWidget.cshtml) you can start by copying the contents from Menu.cshtml to your widget template and continue with modifications from there.
So I would like to know if we should use Parts.MenuWidget-MenuWidget as a literal? It seems that you could only use it for only a single menu in the site then.

Or is it meant to be used like Widget-Name-[MyWidgetName] where we get to provide a unique identifier in the form of the MyWidgetName string?
Dec 28, 2013 at 4:17 PM
I checked using Shape Tracing, it seems to be fixed name.

For multiple menus, you can use widget alternates, which adds alternate names with the zone name menu widget is insterted, e.g. Parts.MenuWidget-MenuWidget-Navigation if the menu is in Navigation zone or Parts.MenuWidget-MenuWidget-Content if it's in Content zone.

Dec 28, 2013 at 11:31 PM
Edited Dec 28, 2013 at 11:31 PM

Thanks for checking!

I got to this question while using Shape Tracing to examine the names.

The foundation of my question is 'how to understand its usage'.

How can I find out if this alternate name is a singleton instance of a widget name that is 'specifically for your widget' as it is described in the quote for stackoverflow?

Currently the information available indicates that there can only be one usage of this name in an entire site-theme-module scope.

Such a thing doesn't seem to fit the Orchard meaning of an 'alternate'.

To reverse the question: for what kinds of things is this Name an alternate?

Who would be willing to tell me?

Dec 29, 2013 at 12:00 AM
My understanding is that: it's an alternate for MenuWidgetPart, attached to a MenuWidget content type. The quoted info is slightly misleading. Not specifically for your widget, but specifically by a MenuWidget. I believe it intends to tell there are menus rendered by non-widget shapes, and if you change Menu or MenuItem templates you would affect them as well.

So if you have one menu widget in your site, you are golden, you can use this alternate. If you have more and you want to target a specific menu widget, you can create more alternates by zone using widget alternates. I'm quite sure there are other entension points you can hook up something like a filter and add an alternate for the menu name (that you define in Navigation) for example, but it seems it's not there out-of-the-box. This would be handy, I think, to target a Menu shape without messing with the widget.

As for the name, highest priority template should win. So even if you have one in your module, the template in the theme should be chosen. I'm not familiar with the Admin theme, but I guess it doesn't use a menu widget, so you are safe there.

Dec 29, 2013 at 12:14 AM
Edited Dec 29, 2013 at 12:16 AM

I truly appreciate the time you spent trying to make sense of this and giving me some insight and confirmation.

I believe the absolute focus of responders on 'what are you trying to do?' is placing an growing 'technology debt' on the progress of the community in understanding Orchard.

Answers to 'what do you want to do' always narrow the discussion to target a specific scenario.

therefore the answers are required to be anecdotal: specific to the scenario.

Anecdotal information is only authoritative when it reaches a statistically significant measuring point, which the count of our individual scenario's that have things in common could possibly reach.

Therefore there is an extremely small amount of authoritative information available for Orchard compared to the frequently useless, scenario-specific anecdotal information.

The imbalance acts just like a backlog of unfinished code: it burdens the forward movement of the entire community on the 'understanding dimension'.

Providing more answers like yours that try to reach a point of understanding the platform is the only thing that will reduce that imbalance.

Dec 29, 2013 at 5:07 AM

One point though. I wanted to participate in other discussions you started with your posts about zone names and data relations but your posts were too hard for me to understand and too general for my experience in Orchard to make a comment. I'm not a native English speaker, and you write like anybody reading is an English major. When I'm not sure what you want to know or discuss, I would like to break it down to smaller parts, divide and conquer. Some of the responses you get might be results of similar behavior. This why you are asked of a specific scenario probably.

This post was an exceptionally clear one for me, and I'm glad you are satisfied with the answers. I will answer as long as I can understand you and to the extend of my knowledge of Orchard, which is not that much to change any balance. Others too I think, if you play nice and don't expect the answer to be as elaborate as your question every time.


Dec 30, 2013 at 3:34 PM
Very insightful, yet kind commentary.

Some people have said that I talk like a book. I always think, 'they should read what I write'.

I just think my level of detail is too much, or my scope is too broad, or both at once.

But your recommendations are well taken.