MVC - Custom ContentRender

Vote:
 

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?

#111980
Oct 21, 2014 16:17
Vote:
 

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.

#111985
Oct 21, 2014 16:47
Vote:
 

You could also use templatedescitor on controls for pagetypes.

#111986
Oct 21, 2014 16:47
Vote:
 

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.

#111987
Oct 21, 2014 16:55
Vote:
 

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

#111988
Oct 21, 2014 16:56
Vote:
 

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

http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2012/10/Custom-renderers-for-properties/

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.

#112095
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.