As i understood what you are after is creating a Widget
. Basically to show any content in your page you must create appropriate ContentType
and attach required parts to it , and to display it you must enter url
of that content in browser's address bar or click in a link for that content which in either case it will navigate to a new page and will display content inside [Content] Zone
. but if you want to display a Content in a special Zone
and special pages, Creating a Widget
is the way to go.to create a widget the only thing required is to add a WidgetPart
to it and give it Stereotype of 'Widget'.you can do this by making following changes in Migration
file for your desired ContentType
:
ContentDefinitionManager.AlterTypeDefinition("MyType", cfg => cfg
.WithPart("WidgetPart")
.WithPart("CommonPart")
.WithSetting("Stereotype", "Widget"));
this will turn your Content Type
into a widget which can be placed in any Zone you want.
to add your widget to a Zone navigate to widgets from dashboard.
and then select the zone which you want to place your widget in :
and then select your widget
and finally select the layer in which your widget will be shown.a layer is set of rules which determine in which pages your widget will be displayed.for example selecting homepage
will display your widget only in home page, selecting default
will display your widget in all pages and so on.to define your own rule check here.
Edit :
to create new zone
in your theme just include the Zone
name in theme.txt
file then open up Layout.cshtml
(one resides in your custom theme's view directory) , and do following :
given your zone name is SecondaryNavigation
then add following code inside your theme
@if (Model.SecondaryNavigation != null)
{
<div id="secondary-navigation" class="group">
<div class="inner">
@Zone(Model.SecondaryNavigation)
</div>
</div>
}
with this an additional Zone
will be displayed in zone list and then you can put your widget inside your newly created zone
.and about that picture you asked about.it is an image file which created by author of the theme and named 'Theme.png' and will displayed as a preview in manage widget screen , you can create it for your own theme and put it in your theme view directory.
EDIT 2
The migration file itself is not important.the only thing which is important is to define a class which drives from DataMigrationImpl
, orchar will pick your migration file and run it automatically , migration file has firstly a Create
method which returns 1 , and for each further update you must define a method called UpdateFromN
in which N
is current version your module is in, that will return 2 , 3 , ... what you can do in a migration file is creating database tables , creating ContentTypes
, ContentParts
, ContentFields
, etc. there is already couple of modules shipped with orchard , check them and get the idea.