Try our conversational search powered by Generative AI!

How to use UIHint / Partial View?

Vote:
 

Hey all,

So i'd like to use a custom renderer for a LinkItemCollection property.  So I can enable the on page editing highlighting and support for a custom rendered link collection.  Problem is, I cannot use the existing linkcollection renderer that PropertyFor uses out of the box, because my list is much more customized with html.  I thought I saw somewhere a tutorial (but can't find it now) as to the way to define a custom renderers for a specific property (not just ALL linkcollections, but for a specific one on a template) in episerver 7.  I'd like to accomplish this by using an MVC partial view (if possible).  I'm just unsure of the correct way to use UIHint and have it use the template i define.  I tried placing a partial view in

/Views/Shared/DisplayTemplates/TestPropertyRenderer.cshtml

and registering an attribute like

[UIHint("TestPropertyRenderer", PresentationLayer.Website)]

and tried even removing the presentationlayer overload.  Much like the original MVC concept works when you use DisplayFor, etc. but with no luck.

 

Any thoughts on how to accomplish this?

Thanks!

#63464
Nov 20, 2012 15:10
Vote:
 
#63486
Edited, Nov 20, 2012 16:45
Vote:
 

Thanks for the link.  I had seen this article previously.  My issue is that it does not lay out how to specify a custom rendering for a specific property on a template (i.e. - customizing the rendering of a link collection for a specific link collection on a specific template), rather it shows you how to override rendering for a whole property type across the cms.

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

But using a view instead of the user control?

#63488
Edited, Nov 20, 2012 18:56
Vote:
 

Does UIHint work for you in this case? You can set an UI hint on the property for the view model (or content type if youre not using view model), and then create a partial view named as the UIHint (for example "myChangedStuff") with the model set to the type youre value type. Hope this can work for you.

#63646
Nov 23, 2012 7:23
Vote:
 

Have you found a solution to this yet? I have the exact same problem, when trying to have a separate DisplayTempalte for a contentarea. If I add a PresentationLayer.Website I get the original UI-Edit control (not the legacy control) which I was after, but then my specific DisplayTemplate stops to work.

Although it all works when I rename my DisplayTemplate to override the standard ContentArea and remove the UIHINT, but then every ContentArea will be run through my control and that is not optimal.

 

Any Ideas?

#73131
Jul 08, 2013 11:16
Ted
Vote:
 

This seems to be a problem indeed. If you set a UIHint and create a corresponding display template, everything seems to work - but for content areas you get a nonfunctional legacy editor. :/

If you do as suggested above and add the presentation layer parameter (setting it to PresentationLayer.Website) it seems the UI hint isn't recognized anymore and the default EPiServer display template is used.

Also, creating a new display template called "ContentArea" may work, but it seems you sometimes get the native display template and sometimes get your own, depending on the inner workings of the MVC initialization. There is already a display template called "ContentArea" in EPiServer, and it seems these collide sometimes. :(

#73319
Jul 15, 2013 15:15
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.