Alternates for overriding a specific field on a specific content type

Topics: Customizing Orchard, Writing modules
Jun 14, 2012 at 3:11 PM

Is it possible to have an alternate that overrides the rendering of a specific field whose parent is a specific content type?

Or anyone know of a way to do this since we really need to differ the layout of a field based on the content type.

Jun 15, 2012 at 5:28 AM

Yes. You can even do it from placement.

Jun 15, 2012 at 7:33 AM

Could you give me an example for both ways? (Alternate / placement)

Jun 15, 2012 at 8:01 AM

I meant you can create alternates from placement

Jun 15, 2012 at 8:55 AM

Ah I see, thanks.

Jun 22, 2012 at 10:22 AM
Edited Jun 22, 2012 at 11:26 AM
bertrandleroy wrote:

I meant you can create alternates from placement

Is it possible that it is broken?

I have 2 custom 'TitleBody' fields on my custom type.

And I'm trying to hide just one:

 <Match ContentType="ProductsIndex">
 <Place Fields_TitleBody-RightPageInfo="-"/>

This hides BOTH my 'TitleBody' fields :/


edit: Ok, seems like I overlooked something (as in make my field compatible for the -Name selector)

edit2: Ok, that seems to solve it. One more thing though, it would be nice if you could declare a custom alternate that points to a subfolder, so we could do stuff like: Alternate=Types__MyCustomType__MyField ?

Jun 22, 2012 at 5:40 PM

The developer of the TitleBody field should add a Differentiator in the field driver. Take a look at the other core fields for an example.

Jun 22, 2012 at 6:17 PM
Edited Jun 22, 2012 at 6:17 PM

Yes, I figured that one out :)

Any reason why the differentiator is optional? (edit: or doesn't have a valid default fallback when not defined)

Jun 22, 2012 at 6:20 PM

You might not want one, I don't know ;) It's better to have options no ?

Jun 22, 2012 at 6:23 PM

Not if it disables a certain (in my eyes) core functionality (targetting fields by field 'name') IMHO.

Given people choices is easy, deciding what ones to make for them, now that is hard ;)