Reputation: 6772
I am developing a custom module for Orchard. I would like to use a Widget on one of my pages in my custom module.
How can I add the widget to a page (display it as a partial view? how to reference it?)?
The goal is to create a home page as a module, when you activate it, it would have all the features with Item Slider Widget - http://gallery.orchardproject.net/List/Modules/Orchard.Module.FeaturedItemSlider. So the widget would be in content part of the page.
Thank you
Upvotes: 2
Views: 2211
Reputation: 4763
You can do this in two ways:
In the module management in the administration add new layer rule. You can specify the url rule with this syntax - url("~/myurl") or url("~/myotherurl") or ...
where you can specify multiple urls where the module will be shown. Next, you can add your widget to that layer. This is OK if you need to show that widget in a small amount of pages.
You can add a new Zone
inside your theme (lets say it will be called MyWidgetZone
). Don't display this zone in your Layout.cshtml
, but rather in the template where you would want to use it (for example in your Content-Page.cshtml
file). To show this zone, you would use this syntax inside your template - Display(Layout.MyWidgetZone)
. All you have to do next is add your widget to MyWidgetZone
inside module management administration and you're good to go..
Upvotes: 5