MVC - Custom ContentRender


In the alloy demo, a customrenderer is used to derive css classes to parse depending on the tag value passed in.

We are using something similiar in terms of we have a customrenderer performing a similiar function.  The problem I am having is, I want to limit this customrenderers usage.  I only want it used either when a particular page type is being rendered, or a property on that page type (either is fine, just didnt know what level its available at).

Theres something similiar done in another project here using webforms, where they have a property with rendersettings, which uses a template descriptor to go to the correct PropertyContentAreaControl, within which they pull in their customrender class.

I cant seem to figure out how to replicate the PropertyContentAreaControl class in the mvc route, looks like it might be a controller perhaps, ala the block previewcontroller?

Oct 21, 2014 16:17

Not sure if it is correct anwser since I might not understand the question. But when I change rendering of properties i use DisplayTemplate concept and use the [UIHint("Yourenderer")] to select templates to be used.

You could also you PresentationLayer on the UIHint-attribute.

Oct 21, 2014 16:47

You could also use templatedescitor on controls for pagetypes.

Oct 21, 2014 16:47

hi eric, theres a bit of overlap of terminology here, which has made searching for the answer difficult!  Im not after a specific displaytemplate, I have a custom GridGalleryContentAreaRenderer class that inherits ContentAreaRenderer and overrides GetContentAreaItemCssClass same as the alloy site.  However, I only want this custom renderer class to be used when a certain pagetype is being rendered (or property, which ever is available or easier).

hope that makes a bit more sense.

Oct 21, 2014 16:55

although I believe there should be some templatedescriptor usage here somewhere.

Oct 21, 2014 16:56

Just for further info, I think what I am after is the mvc equivalent of this webforms technique:

I have this working for every contentarearenderer render at the moment through the existing AlloyContentAreaRenderer example, but I only want to use this contentarearender with certain contentarea properties.

Oct 22, 2014 16:03
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.