Search code examples
c#asp.net-mvcorchardcms

How to create ContentPart in orchard cms theme?


I am trying to design an orchard theme in which i need to attach some Content Part to MenuItem to add some extra info for that.I did the process of adding part as i do inside module ,but strangely enough my view didn't get displayed.after hour's of debugging i figured out that my part's editor shape (eg:Parts_MenuItemMetaPart_Edit) is added to ShapeTable of my frontend theme rather than admin theme(TheAdmin) and thus my attached part editor not displayed.so is there any possibility to create a content part from within theme?if yes, how ?


Solution

  • Just found this link : https://github.com/OrchardCMS/OrchardDoc/blob/master/Documentation/Add-Custom-Settings-to-your-Theme.markdown

    from the link above :

    ... You may be wondering why we don’t just use a driver like we usually do for a parts editor template. This is due to the fact that to call the Editor method of your Driver and return a shape, you need to have specified in the Placement.info that you want to do that. Since this theme is not active in the admin section of Orchard, our themes Placement.info file is never run hence a Driver would never display anything...

    So the solution is to add ActivatingFilter in ContentPartHandler like this :

    Filters.Add(new ActivatingFilter<MyPart>("Site"));
    

    for more info follow the link provided.