Delegate properties

Topics: Core, Localization, Nederlands (Dutch)
Jul 23, 2013 at 9:21 PM
Hey guys.

I have a question about the (very good) article of Spike:

In this part The T or @T localization is mentioned as a property delegate. I would like to achieve the same with a substitution of a text after for example @S("S1") in a Razor template.
I created a substitution part with one field, the placeholderID (the "S1") and created a contenttype with a body part and my substitutionpart. The body part contains the data to replace the test (placeholder) behind the @S. Is it easy to create such a property delegate which is applicable to all razor webviews?
Jul 28, 2013 at 9:23 PM
What you would have to do is either add this property to a couple of base classes (I believe Orchard.Mvc.ViewEngines.Razor.WebViewPage<TModel>, Orchard.Mvc.ViewPage<TModel> and Orchard.Mvc.ViewUserControl<TModel>, or derive classes from these and add your property there. If you do the latter, you will have to update web.config and configure system.web.webPages.razor/pages.pageBaseType to use your own type. Perhaps you need to do more, but you'll discover that as you go. As an example, look at how the T and H properties are implemented in Orchard.Mvc.ViewPage<TModel> in Orchard.Framework/Mvc.
Jul 29, 2013 at 7:29 AM
Thanks Spike.
You were right. I did derive from the classes you described and found out I had to update the web.config. I'll move on from here.

Thanks for your quick response.