Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andrei 64 posts 115 karma points
    Mar 27, 2015 @ 10:34
    Andrei
    0

    Is it possible to override/replace TextStringValueConverter?

    Hi all,

    I need to change how local links are parsed in rte fields and a good fix would be if I could alter a bit TextStringValueConverter. This way I can fix everything in one place.

    Not sure how converters work, but it looks like they are hooked via attributes, like [PropertyValueType(typeof(string))] [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Request)] public class TextStringValueConverter : PropertyValueConverterBase{..}

    If I make my own, how can I plug it in to replace the standard one? Or is that even possible?

    [Update] - actually I may have been a little wrong and need to change another converter (the one for rte values) not TextStringValueConverter. But still is this possible?

  • Andrei 64 posts 115 karma points
    Mar 27, 2015 @ 16:00
    Andrei
    0

    I ended up making two conververs one for Text and one for Rte. Then I had to remove the standard umbraco converters in AppStarting event like this:

    protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
    {
        // remove standard umbraco converters, because we have made custom ones in order to fix the anchor links
        PropertyValueConvertersResolver.Current.RemoveType<Umbraco.Web.PropertyEditors.ValueConverters.TextStringValueConverter>();
        PropertyValueConvertersResolver.Current.RemoveType<Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter>();                        
    }
    

    otherwise I would get duplicate converters conflict. Looks like it's working.

Please Sign in or register to post replies

Write your reply to:

Draft