Copied to clipboard

Flag this post as spam?

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


  • Niels Henriksen 74 posts 277 karma points
    Apr 23, 2020 @ 10:51
    Niels Henriksen
    0

    Event when CSS, JS or Template is saved

    Are there an event I can fire when Umbraco save a CSS, JS or a Template?

    My problem is that my customer sometime is changing CSS on his website in Umbraco and when he ask me to make some more changes to them I make the changes in my local files for later to push them to github.

    Well. the problem is then that his changes is overwritten if he forget to tell me that he has made changes.

  • Søren Kottal 713 posts 4571 karma points MVP 6x c-trib
    Apr 23, 2020 @ 11:41
    Søren Kottal
    100

    Hi Niels

    Thats a great idea for dealing with curious and adventurous clients :)

    There is a bunch of events in FileService you can listen for, ie. SavedScript, SavedStylesheet etc.

  • Niels Henriksen 74 posts 277 karma points
    Apr 23, 2020 @ 13:31
    Niels Henriksen
    0

    thanks :) I will look at that

  • Niels Henriksen 74 posts 277 karma points
    Apr 23, 2020 @ 13:52
    Niels Henriksen
    0

    Now I feel I have control on his site again :D

    I found out to do like this

    class StylesheetChangedComponent : IComponent
    {
        public void Initialize()
        {
            FileService.SavedStylesheet += Stylesheet_Saved;
        }
    
        private void Stylesheet_Saved(IFileService sender, SaveEventArgs<Stylesheet> e)
        {
            foreach (var savedItem in e.SavedEntities)
            {
                var content = savedItem.Content;
                var path = savedItem.Path;
            }
        }
    
        public void Terminate()
        {
            FileService.SavedStylesheet -= Stylesheet_Saved;
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft