Copied to clipboard

Flag this post as spam?

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


  • Anders Brohäll 295 posts 561 karma points c-trib
    Sep 20, 2017 @ 11:02
    Anders Brohäll
    0

    Is it possible to populate properties in backoffice on creation?

    I'm wondering if it would be possible to pre-populate fields in the Back-office when creating contents.

    For example, let's say that i want to populate a textbox with the creators IP-address. Of course i can do it with the save/saved/publish/published-events, but if possible I'd prefer if it were already typed in when first rendered.

    How would I do that?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 20, 2017 @ 11:08
    Ismail Mayat
    1

    Anders,

    You could create your own property editor that is just label that autopopulates users ip address. Then put that property editor on a base doc type or use a composition.

    Regards

    Ismail

  • Anders Brohäll 295 posts 561 karma points c-trib
    Sep 20, 2017 @ 11:17
    Anders Brohäll
    0

    I could! But what if i wanted it to be applicable to any property. Like if i had a template that i wanted to string.Format with something like the users name?

    Something like:

    string.Format("Lorem ipsum dolor sit amet, consectetur adipiscing elit. {0}, {1}}", userName, ipAddress). 
    

    The example is somewhat crude, but I would like a event or such to be able to modify - or pre-populate data. Pretty much the same way I can handle the properties in the events mentioned above.

    I'm not asking for help with a specific problem, rather looking for a general approach to it.

    :)

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 20, 2017 @ 11:27
    Ismail Mayat
    0

    v 7.7 has templates formerly known as blue prints maybe that can help https://umbraco.com/blog/hello-umbraco-77/

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Sep 20, 2017 @ 11:29
    Kevin Jump
    100

    The 'unsupported' but seems to work route i have used a few times is to use the ContentService.Created events (which have been obsoleated) but do fire when editors create new content in the UI (but i don't know for how long) - seems to work upto latest v7.6.x release)

    You could also look at Angular Interceptors which allow you to intercept the javascript as it loads up the content.

    You could also look at a Delegating Handlers which is a way to do similar things to Angular Interceptors from the back office (so in c#)

    Umbraco 7.7 has Umbraco Blueprints. which might be the easiest way (if you don't want dynamic values).

    and you could write your own property editors - which could load values dynamically when they are loaded onto the editor page by umbraco ?

    I am bad - so i've done the top one (ContentCreated) and it works, for now....

  • Anders Brohäll 295 posts 561 karma points c-trib
    Sep 20, 2017 @ 11:37
    Anders Brohäll
    0

    Thank you Kevin! I'd look into these. I guess that ContentService.Created it pretty much what I'm looking for. In my specific scenario the creation of the node will always be initiated by a user in the back-office. So I assume that the event will be triggered 100% of the times.

  • Anders Brohäll 295 posts 561 karma points c-trib
    Sep 20, 2017 @ 12:40
    Anders Brohäll
    0

    Just saw that the ContentService.Created (nor Creating) isn't deprecated in the code base. To whoever it may concern.

    :)

Please Sign in or register to post replies

Write your reply to:

Draft