Alternates not overriding if general override is present

Topics: Writing modules, Writing themes
Developer
Mar 10, 2012 at 11:46 AM

I have the following scenario:

In one module (3rd party) there is a shape template Parts.Common.Metadata.cshtml, overriding how metadata from CommonPart is rendered. In my module I'd like to override metadata rendering, but no matter how I do it following shape alternate naming conventions, it doesn't kick in, the template from the 3rd party module is rendered.

This is understandable with generic template names, but also if I try more specific alternates (like Part.Common.Metadata.MySpecificDisplayType.cshtml) nevertheless the one from the 3rd party module is rendered.

The only way to override the shape is to use the Shape attribute in Placement.info. This is fine, but shouldn't alternates work as I expected them?

Thanks in advance!

Developer
Mar 10, 2012 at 12:06 PM

I believe that should work. I did so myself at one point (I can't remember exactly when or where). Did you try to temporarily rename the template of the 3rd party module to see if your alternate works at all?

Developer
Mar 10, 2012 at 1:18 PM

Thanks! I've come to the following:

It looks that I've misunderstood how alternates work. The fact is that there are only three possible shapes for CommonPart: Parts_Common_Metadata, Parts_Common_Metadata_Summary, Parts_Common_Metadata_SummaryAdmin. So one can only use these, it's not possible to override them like I tried.

The solution is pretty simple:

  • Parts.Common.Metadata.MySpecificDisplayType.cshtml as it was
  •   <Match ContentType="MyType" DisplayType="MySpecificDisplayType">
        <Place Parts_Common_Metadata="Meta:25;Shape=Parts_Common_Metadata_MySpecificDisplayType"/>
      </Match>
Developer
Mar 10, 2012 at 4:07 PM

Awesome, I totally overlooked the docs that you can change the shape names like that!