Copied to clipboard

Flag this post as spam?

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


  • steschu 88 posts 489 karma points
    Jun 30, 2019 @ 13:38
    steschu
    0

    built-in property editors: how to inherit and set configuration options

    Hi,

    I know that built-in property editors are located here (\Umbraco\Views\propertyeditors...) and the controllers here (\Umbraco\Js\umbraco.controllers.js).

    Can anybody tell me where the equivalent to the manifest file is for the buil-in editors? I wonder e.g. where the maxChars limit configuration option is declared for the normal textbox property editor? Cannot find any manifest files..

    Further, if I want to add some simple functionality to the existing umraco controller for a property editor, is there a preferred way to inherit somehow? I am not very good at angular yet, but some keywords to google for should help.

    Thanks, Stephan

  • steschu 88 posts 489 karma points
    Jul 01, 2019 @ 08:51
    steschu
    0

    Anybody any idea?

  • Kevin Jump 2341 posts 14868 karma points MVP 8x c-trib
    Jul 01, 2019 @ 11:56
    Kevin Jump
    100

    Hi Stephan,

    this are some differences between Umbraco 7 and Umbraco 8 so it will depend on which one you are looking at.

    Umbraco 7

    (Tutorial if you haven't seen it https://our.umbraco.com/Documentation/Tutorials/Creating-a-Property-Editor/)

    The Textbox Property Editor is defined in this class : https://github.com/umbraco/Umbraco-CMS/blob/v7/7.14/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs

    You could, in theory, inherit this class and add extra values, but if you are using models builder you would also need to have your own ValueConverter which converts the stored data to and from a string.

    Umbraco 7 Example The StyledTextBox Package has code similar to this ( https://github.com/KevinJump/StyledTextbox/tree/master/StyledTextBox.WebSite/App_Plugins/StyledTextbox ) It doesn't override the base values, but does create property editors that can directly replace them with additional values for styles, enforcing limits etc.

    Umbraco 8

    In Umbraco 8 there is a textbox property Editor class https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs

    this defines the configuration (so the class containing the settings) https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/PropertyEditors/TextboxConfiguration.cs

    and the configuration editor (https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/PropertyEditors/TextboxConfigurationEditor.cs) which defines how the data type configuration works (in the case of the default editors it shows the parameters defined in the Configuration class).

    you have to override all of these, and add extra implimentation details to the configuration for them to then appear in your datatypes/property editors.

    Umbraco 8 Example - StyledEditors Package https://github.com/KevinJump/Our.Umbraco.StyledEditors/tree/dev-v8/Our.Umbraco.StyledEditors has a load of over-rides of the base text/numeric classes to add things like css/style attributes, this does the overriding of the base values so for Umbraco 8 it is the exact way you would need to do it.

  • steschu 88 posts 489 karma points
    Jul 01, 2019 @ 12:33
    steschu
    0

    Hi Kevin,

    Thanks a lot for your reply. As I understand the textbox config is coded in the umbraco source code, thus not appearing as textstring somewhere in the solution, but compiled in one of the dll files, right?

    Actually my property editors aren't a real package yet. I simply put my html, js, css ... files in the App_Plugin Folder. I will take a look at your styled editors project. Should be an incentive to develop things like you do.

    Cheers, Stephan

Please Sign in or register to post replies

Write your reply to:

Draft