customize list module in orchard - orchardcms

I want to have my custom lists module in my orchard project
for that: I copied all schema(include handler, controller , views, ...) from
default Orchard.Lists module to MyList Module.
when I run MyList module, and I click the Contained Items() link in UI, this exception crashed in a view with name: "Parts.Container.BulkActions.cshtml :
Cannot convert type 'Mypro.MyLists.ViewModels.ContentOptions' to 'Orchard.Lists.ViewModels.ContentOptions'
I know what's mean:
but , I changed all namespace and area name in Routes file. I don't know why my module redirects to the view(Parts.Container.BulkActions.cshtml) that belong to defualt orchard.lists module? instead of redirect to the view in my module?

Related

Alternate shape for EditorTemplate of Field is not being recognized

I need an alternate for the EditorTemplate of an Enumerator Field that's used when the Field has a particular name (PublishingMethod).
Based on the docs, I created a view with the pattern [ShapeType__FieldName] in the same folder as the original shape:
This is not working and still uses the original. I've thought of changing the Editor method in the Driver, but I think that defeats the purpose of alternates, which is that Orchard automatically detects the correct shape as I understand from the docs:
The Orchard framework automatically creates many alternates that you can use in your application. However, you can create templates for these alternate shapes.
Note: I can't use the Shape Tracing module, it never worked even with a clean Orchard install.
The editors in Orchard work different to how Display works. I guess it is so you get a MVC-style experience. Basically, the actual shape returned is of type EditorTemplate, which then binds your model and prefix then renders a partial view with the template name you gave it. What this means is alternates wont work as expected, or as the docs state. The alternates for your field name are actually added to the EditorTemplate shape. So what you can do is add a view called EditorTemplate-PublishingMethod.cshtml with contents like:
#{
var m = (Orchard.Fields.Fields.EnumerationField)Model.Model;
}
#Html.Partial("PublishingMethodEditor", m, new ViewDataDictionary {
TemplateInfo = new TemplateInfo { HtmlFieldPrefix = Model.Prefix }
})
Then add another view called PublishingMethodEditor.cshtml with the overrides you want for your editor. All these views should go in the root of your Views folder.
Another approach would be to implement the IShapeTableProvider interface and adjust the TemplateName property on a certain condition but, meh, that requires code...
Edit 1
If you have that field name on other content types that you don't want to override you can use the override EditorTemplate-ContentTypeName-PublishingMethod.cshtml

Opencart add new custom page to search results

I have been looking through many forums but I was unsuccessful :(
I need to display the content of a OpenCart custom page in the search page.
Ta very much
You just need to execute that custom controller, save its output in the data list of the search page template and display it there where ever you want
(1) Open the file "<OC_ROOT>/catalog/controller/product/search.php", you will find a class named "ControllerProductSearch", we are interested in the function "index()"
(2) Find the statement
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
(3) Add the route of your custom controller in the array $this->children, now OC will automatically evaluate your custom controller and send the HTML in a variable to the template, the variable name will be the last component in the route (e.g if your route is common/my_customer_controller, the name will be $my_custome_controller)
(4) Open the search page template file "<OC_ROOT>/catalog/view/theme/<YOUR_THEME_FOLDER>/template/product/search.tpl", and use the variable there
P.S. Make sure that you define your custom controller in the same way other controllers are defined (file naming style, class name based on the route ...), other wise the above solution won't work

Reuse same view across modules

This question is specific to Orchard CMS.
I have a partial view defined in a shared project. This partial view i would like to include in all the display views defined in other modules.
e.g Let's say I have a partial view with a label "Copyright information" defined in project "Shared".
I add a new module in Orchard, in Display view i would like to include this view. Copyright label is just an example, my requirement is to reuse form elements across modules.
You can create your own shapes, then create templates for them in the views directory of your module. Other modules can then reuse those shapes if they take a dependency on the first module. They can even override templates if they need to. Your theme can also override templates.

Zf2 define child layout for entire module

I want to create a navigation for Application module as the main navigation containing all module, and a navigation for each others modules containing all controllers of this module.
It will rendered at the last like tabs with subs tabs depending of the active page.
I want to do this with child layout, without inserting $view->layout()->addchild(..) in each action of each controllers of each module.
In each Module's Module.php file you can attach a custom event in the onBootstrap method to set whichever template you wanted:
//Attached in the onBootstrap method of Module.php
public function determineLayoutEvent(\Zend\Mvc\MvcEvent $event) {
$view = new \Zend\View\Model\ViewModel();
$view->setTemplate('custom/custom_layout');
$event->setViewModel($view);
}
I would do something like that^^.
There might be a hiccup or two with the code I've given when appending the actual view from the controller, but this should be a decent start.

Mixing Orchard CMS content with module

I am currently working on an Orchard module. This module contains an MVC application including the views. I would like to make the module as configurable as possible. One of the items that I would like the customer to configure is the way the MVC views from the module look. Part of it will be determined by the theme. But not everything. Consider the following scenario:
The module contains a view for placing an order. The view displays a form in ´normal view way´. That is field labels and input labels. But at the head of the form each customer must be able to define his own set of instructions to display. Or maybe the customer wants to put there a message for pointing the customer to some other actions.
In the most ideal way I would have a content page where the customer can put all kind of content and one specific block that is the result of the view of the module. Kind like a web part. I can´t find out if it is possible and how that is achieved.
Edit for clarification
Module creates a page like this:
TITLE
FORM
So both title and form are outputted by the module controller.
I have managed to create a layer with the condition that the url matches the page with my form.
I have added a HTML widget to this layer in the content zone with position 1 (tried 0 to).
However the pages looks like this:
TITLE
FORM
WIDGET
instead of
WIDGET
TITLE
FORM
Returning a ShapeResult from your controller action will ensure that your view is themed and benefits from widgets, which are your "kind like a web part" thingies in Orchard.

Resources