Alternate for TitlePart

Topics: Writing modules
Oct 9, 2012 at 11:10 AM

Hi all,

I'm trying to modify the label of the TitlePart and BodyPart I use in a custom ContentType. I've tried using alternates, but i've just started learning Orchard and finding it a bit confusing. Could someone please help me out on this one. I know there are alternative solutions, just looking for the best one.

Second question: I also want to get rid of the "Set as homepage" checkbox in the autoroute part. How would i do this?

Any help would be much appreciated.

 

Developer
Oct 9, 2012 at 1:54 PM

Hi Line20,

Have you used ShapeTracing? If you switch that on, it will give you a better idea of the avalible alternates.

The Set As Homepage is a Permission. Just go in to the role, and uncheck that permission.

Nick

Oct 9, 2012 at 2:31 PM
Edited Oct 9, 2012 at 2:59 PM

Hi Nick,

Thanks for your help. I have tried using the designertools. But they do not seem to be available in the dashboard (admin views)?

Line20.

Developer
Oct 9, 2012 at 4:59 PM

No they are not, the Admin view is not really made up the same way as the front facing UI.

Are you saying you want to override those edit views?

Coordinator
Oct 9, 2012 at 5:02 PM

You won't be able to use alternates from a theme either because your theme won't be an admin theme. The only way would be to have a module that would take a dependency on what it's trying to override and override the templates and/or placement from there. Or change the shape from a shape table provider. In either way, it's a module.

The set as homepage checkbox can be easily removed by revoking that right in the user/roles screen.

Oct 10, 2012 at 9:02 AM
Edited Oct 10, 2012 at 9:12 AM

Hi all,

Thanks for the replies. @bertrandleroy: I figured I would have go that direction. I'm trying to overwrite "..\Core\Common\Views\EditorTemplates\Parts.Common.Body.cshtml" and "..Core\Title\Views\EditorTemplates\Parts.Title.TitlePart.cshtm". Where I would like to change the label for both parts. I included the TitlePart view as an example where I marked the label declaration "green".

@model Orchard.Core.Title.Models.TitlePart

<fieldset>
    @Html.LabelFor(m => m.Title, T("Title"))
    @Html.TextBoxFor(m => m.Title, new { @class = "large text", autofocus = "autofocus" })
    <span class="hint">@T("You must provide a unique title for this content item")</span>
</fieldset>

I figured I could add a file like  "Views\Parts_Title_TitlePart_Custom.cshtm" to my module. and add a line to placement.info to make it use that file to render. But I that isn't going to work I guess.

<Match ContentType="CustomType">
    <Match DisplayType="Detail">
      <Place Parts_Title_TitlePart="Content:0;Alternate=Parts_Title_TitlePart_Custom"/>
    </Match>
  </Match>

Maybe I could change the shape in code. I guess I would have to do this in the driver for the contenttype I created.  Just don't know how to do it?

Coordinator
Oct 10, 2012 at 5:29 PM

No, not in your driver, in a shape table provider.

Apr 2, 2014 at 8:19 PM
I really need to get something along these lines up and running. In a nutshell I just want render a custom TitlePart editor template for a specific content type (i'm writing a module).

I've successfully overridden the title part view by creating the following file:

Views/EditorTemplates/Parts.Title.TitlePart.cshtml

But obviously this overrides the view for all content types. I can't find a way to customise for a specific content type. Any help would be REALLY appreciated.

Thanks in advance!