Theme Placement file is not overriding module placement file

Topics: Troubleshooting, Writing themes
Jul 27, 2012 at 2:13 PM

Hi,

I am running Orchard 1.4.2.

I have a custom theme based on an unmodified "The Theme Machine".

My custom theme defines the following placement.info file

<Placement>
    <Place Parts_Autoroute="-"/>
    <Place Parts_Autoroute_Edit="-"/>
    <Place Parts_Autoroute_SummaryAdmin="-"/>
    <Place Parts_Autoroute_Summary="-"/>
</Placement>

Am I correct in expecting the Autoroute part to be removed from all items when using this? The permalink and "set as home page" checkbox is still visible when I view content in the dashboard.

Is there something I might be missing here?

Thanks

Coordinator
Jul 27, 2012 at 3:10 PM

What you're missing is that your theme is not an admin theme so only the first Place ever applies.

If you want to remove the Autoroute part, why don't you do just that: remove the part from the type?

Aug 1, 2012 at 1:30 PM

Hi

I had a similar issue :)

If I modify the current autoroute module's placement.info file:

<Placement>
    <Place Parts_Autoroute_Edit="Content:before.51"/>
</Placement>

to

<Placement>
    <Place Parts_Autoroute_Edit="-"/>
</Placement>

It removes the autoroute part from the edit view in the admin section (so I know the syntax for the placement of that edit part is correct)

What I see now, is that the custom themes don't effect the dashboard area at all, and you need to add/edit the TheAdmin Theme placement.info file.

I tried adding it to a custom module's placement info, but that also doesn't work.

Am I correct in thinking that if you wanted to cusomise the dashboard you need to modify the TheAdmin Theme?

Developer
Aug 1, 2012 at 1:56 PM

Only one theme is active at a time, so you cannot use other themes to override TheAdmin theme. However, the dashboard can be customized in a lot of different ways, so it depends. For example, using Admin based Placement, you don't have to modify Placement.info of modules or TheAdmin in order to move around admin shapes. Another example is injecting new menu items, or even implementing new admin screens. But if you for example wanted to replace the Orchard logo with your own, that would require modifying TheAdmin theme.

Aug 1, 2012 at 5:14 PM

sfmskywalker: are you sure with this? i think there are multiple active themes, but only one is "current". And you can replace the logo with custom theme if the theme has an priority above 100, setting this in your custom IThemeSelector impl. Or am i missing something?

public class MyAdminSelector : IThemeSelector
    {
        public ThemeSelectorResult GetTheme(RequestContext context)
        {
            if (AdminFilter.IsApplied(context))
            {
                return new ThemeSelectorResult { Priority = 110, ThemeName = "MyAdmin" };
            }

            return null;
        }
    }
Developer
Aug 2, 2012 at 1:31 AM
Edited Aug 2, 2012 at 1:31 AM

I'll admit that I haven't studied the theme selection code in-depth, but in the end, only one "winning" theme is being used for rendering the page. The code you're showing looks like it should do the trick in overriding the TheAdmin theme with your own admin theme. However, what I meant was is that you cannot override things like Placement.info in the admin by simply setting your own custom theme with a Placement.info file, even if it's set as "current". The code you're showing is causing the "MyAdmin" theme to be the current/active one for the HTTP request. I suppose that if you derive your custom admin theme from TheAdmin, you could then override Placement.info in that way. Which would be rather neat. Thanks for pointing this out!

Aug 7, 2012 at 6:14 PM
Edited Aug 7, 2012 at 6:16 PM
bertrandleroy wrote:

What you're missing is that your theme is not an admin theme so only the first Place ever applies.

If you want to remove the Autoroute part, why don't you do just that: remove the part from the type?

Becuase I don't want to lose the functionality of it. If I add a Autoroute part to a custom type and set the part setting "AllowCustomPattern" to false, then there is still some functionality added to the type even though the user cannot modify it (i.e. the Permalink textbox is disabled). All that I want to do is remove that redundent textbox since noone can use it in that context.

It seems that it should be possible, because if I do the same with the metadata template, is disappears. Here is the placement of my custom module that contains the custom type:

 

<Place Parts_Common_Metadata_Edit="-"></Place>

The above placement is removing the metadata template from the dashboard from within the custom module's placement.info file, why can't I do the same with the autoroute template (as below:)?

 

<Place Parts_Autoroute_Edit="-"></Place>

 

P.S. Sorry for the long delay, (was on holiday)

Aug 8, 2012 at 10:20 AM

I'm not sure what I am doing wrong, but the placement of items seem random at times. Is there an order of loading/using placement.info files? What would happen in the following scenario:

A built in module like the Autoroute part defines this placement:

<Place Parts_Autoroute_Edit="Content:before.51"/>

A custom module defines a new content type that uses the autoroute part and defines this placement:

<Place Parts_MyCustomPart_Edit="Content:5"></Place>
<Place Parts_Autoroute_Edit="-"></Place>

The theme does not define any significant placements.

Am I wrong in assuming that this should remove the autoroute part from the view when viewing the custom part? It doesn't.

Aug 8, 2012 at 10:33 AM

And here's another example like the above: I have a media picker field on a custom type that I do not want to display in the SummaryAdmin displayType.

I've tried all the below entries to my placement file of my Theme and module defining the custom type, but none works:

        <Match DisplayType="SummaryAdmin">
            <Place Fields_MediaPicker="-"/>
        </Match>
<Place Fields_MediaPicker="-"/>
<Place Fields_MediaPicker__SummaryAdmin="-"/>

What really baffles me is that this sort of thing works in some cases but not in others? For instance the Bing.Maps Module. I use the below placement to remove it from the SummaryAdmin display type!

       <Match DisplayType="SummaryAdmin">
            <Place Parts_BingMap="-"></Place>
        </Match>
Developer
Aug 8, 2012 at 5:03 PM

That makes sense: your Bing.Maps module generates the Parts_BingMap shape, and the placement.info file is the only one in the system that specifies where to put that shape (in your case: nowhere). But if you were to write another module that also had a placement.info file with a different setup for the Parts_BingMap shape, there's no way of knowing which placement.info gets executed last. It may depend on naming sort order. Unless the other module would have a dependency on Bing.Maps - I didn't try this, but perhaps that will cause the placement.info of the other module to override the one from Bing.Maps.

If that works, what you could do is create a new custom theme, e.g. CustomAdmin, and derive it from TheAdmin. There's a good chance that CustomAdmin's placement.info file will override the one from TheAdmin.