Copied to clipboard

Flag this post as spam?

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


  • John Bergman 483 posts 1132 karma points
    Jan 30, 2019 @ 18:24
    John Bergman
    0

    USync Content - protecting specific nodes

    Question: I'd like to protected a few nodes from being overwritten by usync in one of our implementations.

    Has any thought been giving to adding a "magical" property called something like "usyncIgnore" or "usyncReadonly"? That way the code that imports could just skip it if the property is set?

    Otherwise what's the impact to adding an event handler that prevents the node from being saved, How would I best do that without impacting the rest of the usync import process (i'd prefer not to have a redbar error message)?

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Jan 30, 2019 @ 19:18
    Kevin Jump
    101

    Hi

    Good news - there are some secret settings to stop nodes being overridden :)

    on the content handler, you can add extra settings: https://usync.readthedocs.io/handler-config/#custom-handler-actions

    the one you are looking for is ignore where you can put the path to the content you don't want to overwrite.

    <HandlerConfig Name="uSync: ContentHandler" Enabled="true">
      <Setting Key="ignore" Value="home\blog\example" />
    </HandlerConfig>
    

    You can comma separate so, for example, home\blog,home\shop would skip both blog and shop.

    -

    The only other extra thing is that sometimes you might still want the content writing out to disk, but not importing into your target site - for this, you can set the rulesonexport setting to false - then the rules won't count on export/save so everything is still on disk, even if it doesn't go back into your target site.

  • John Bergman 483 posts 1132 karma points
    Feb 02, 2019 @ 22:36
    John Bergman
    0

    Hey Kevin, quick question... is the list case sensitive? How does the umbraco properties (like umbracoNaviHide and umbracoUrlName) play into this?

    If my path is:

    enter image description here

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Feb 02, 2019 @ 22:46
    Kevin Jump
    0

    Hi,

    It's the path as usync would write it to disk, which uses the Umbraco function ToSafeFileName.

    I think in your case that would probably be SiteConfiguration/SiteSettings.

    Content properties have no effect it's all based on the path.

    Kevin

  • John Bergman 483 posts 1132 karma points
    May 17, 2019 @ 06:22
    John Bergman
    0

    Hey Kevin, just another quick question, does it ignore all the child nodes? So in the example above if I used SiteConfiguration, would it also ignore the 3 nodes below it? The documentation isn't clear about that.

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    May 17, 2019 @ 08:42
    Kevin Jump
    0

    Yeah it should ignore anything starting with that path.

    K

  • nonoandy 6 posts 26 karma points
    Aug 24, 2020 @ 20:34
    nonoandy
    0

    Kevin first thank you for these cool plugins that help keep things controllable.

    Before I go off and try to make this :) Do you think it would be possible to extend the properties (at least in edit mode) to have a ignore flag? or in put the list in the uSync Settings area?

    I am not a fan of putting url-paths in my config files where I don't want most normal users.

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Aug 25, 2020 @ 08:12
    Kevin Jump
    0

    Hi

    How do you see the ignore flag working? a certain type of property (like say uSyncIgnore) or something more where you define some rules ?

    All for making it a bit easier - we had a play a while back with making the per handler settings show up in the UI, it just needed some finessing, but in principle its all possible.

    In the meantime If you do think you need to write something the shortcut to that would be to implement a new content handler that inherits uSync8.ContentEdition.Handlers.ContentHandler and then override the ShouldImport function (which it inherits from ContentHandlerBase). this is what usync currently calls to work out if the thing should be imported.

    https://github.com/KevinJump/uSync8/blob/v8/dev/uSync8.ContentEdition/Handlers/ContentHandlerBase.cs#L138

    (of course if you want to do it and send a PR, its more than welcome - currently v close to release 8.7 on v8/8.7-main branch)

    Kevin

  • nonoandy 6 posts 26 karma points
    Aug 25, 2020 @ 13:57
    nonoandy
    0

    Thank you! Yes a simple boolean flag like uSyncIgnore is what I was thinking of or a list in the UI would do too.

    I will look into the information you sent me and see what I have time to do!

    Getting fancy my other ideas would be

    1. uSyncIgnore flag on
         a. control level (ignore 1 control)
         b. section level (ignore a group of controls)
         c. page level (ignore a page). 2
    2. Another idea because people do strange things with content, an option list
        a. Option - Ignore Do Not Touch
        b. Option - Ignore But Allow Removal
        c. Option - Ignore But Update If Blank
        d. Option - Custom Script Entered in uSyncSettings
  • Anton Oosthuizen 206 posts 486 karma points
    Apr 22, 2021 @ 11:41
    Anton Oosthuizen
    0

    Hi guys,

    Is it possible to ignore certain datatypes ?

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Apr 22, 2021 @ 11:55
    Kevin Jump
    0

    Hi Anton,

    not with the config as it stands, at the moment you can exlude based on content path,

    but if you wanted to do something like ignore certain document types the same advice as above. would be to write a custom ContentHandler that inhetits from uSync8.ContentEdition.Handlers.ContentHandler and override the ShouldImport method.

    something like below would do it.:

    protected override bool ShouldImport(XElement node, HandlerSettings config)
    {
        // check base first - if it says no - then no point checking this. 
        if (!base.ShouldImport(node, config)) return false;
        var ignoreTypes = config.GetSetting("IgnoreDocTypes", string.Empty).ToDelimitedList();
        var contentType = node.Element("Info")?.Element("ContentType").ValueOrDefault(string.Empty);
        if (ignoreTypes.InvariantContains(contentType)) return false;
    }
    

    Equally if you wanted to throw this or something similar into a PR on the repo, we would happily look at adding it to the core handlers.

    Kevin

  • Anton Oosthuizen 206 posts 486 karma points
    Apr 22, 2021 @ 11:58
    Anton Oosthuizen
    0

    Shot Kevin,

    You're a freeknin rockstar.

    Always so quick to reply

  • Anton Oosthuizen 206 posts 486 karma points
    Apr 22, 2021 @ 12:02
    Anton Oosthuizen
    0

    So will this work for datatypes as well ?

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Apr 22, 2021 @ 12:27
    Kevin Jump
    0

    Hi

    I depends on where you want to ignore the datatypes.

    if you don't want certain datatypes to import then there are already some specific settings you can put in the uSync8.config file to stop certain things importing by name or by editor type.

    https://docs.jumoo.co.uk/uSync/v8/uSync/handlers/#handler-specific-settings_1


    if you want certain properties on a content item not to import by datatype then thats a bit more complex (and would require the override method above to be a bit clever).

    Mainly because of performance at the point that the ShouldImport method is called uSync doesn't actually have a copy of the content item (and it may be new so it may never get it).

    If you needed to say don't import property x because its of datatype y then you would have to do the lookup in the ShouldImport method

    • so you would have to find the ContentType
    • then read its properties to work out what datatype each one is,
    • and then you would have to remove the property by alias from the XML that is passed to the method
    • but you might need to get the content item, and read in the existing value and put that in the XML so the value doesn't get removed (haven't tested this).

    do able - if you needed it to be - but it would be a bit fiddly, and all those lookups would slow down the syncing by a bit.

    what we don't have is the concept of read only properties on sync and maybe that is what we would need to look at to make this more sensible.

  • Mahmoud 15 posts 85 karma points
    Feb 09, 2022 @ 12:26
    Mahmoud
    0

    Hi Kevin,

    Is it possible to allow only content creation and not to update the existing content? We have a case that client may do some customization to a page so if we have a new release we don't want to override his customizations to existing pages but rather want to create only new pages. I'm using Umbraco 7

    Thank you

    Mahmoud

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Feb 09, 2022 @ 12:44
    Kevin Jump
    0

    Hi Mahmoud,

    yes, you can make a handler create only in config: (see docs http://usync.jumoo.co.uk/docs/8.x/reference/handlers#handler-specific-settings)

    so for content this may look like:

    <Handler Alias="contentHandler" Enabled="true" Actions="All">
        <Add Key="CreateOnly" Value="true" />
    </Handler>
    
  • Mahmoud 15 posts 85 karma points
    Feb 10, 2022 @ 10:26
    Mahmoud
    0

    Hi Kevin,

    I'm afraid this setting is not working on Umbraco 7, do we need to upgrade to Umbraco 8 then ? this is the version of uSync that we are using (latest version in terms of Umbraco 7) enter image description here

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Feb 10, 2022 @ 10:44
    Kevin Jump
    0

    Hi,

    yeah its not really doable out of the box with uSync 4 :( . and for uSync v4 we aren't doing any active development anymore.

    but you could overwrite the content handler (with your own class that inherits) https://github.com/KevinJump/uSync-Legacy/blob/v4_master/Jumoo.uSync.Content/ContentHandler.cs#L35

    you would probably 'only' need to overwrite the Import class, to take the incoming file and see if the content item already existied, (and it if does, don't run the import command).

  • Mahmoud 15 posts 85 karma points
    Feb 10, 2022 @ 17:34
    Mahmoud
    0

    Thanks Kevin, much appreciated!

  • Mahmoud 15 posts 85 karma points
    May 10, 2022 @ 11:19
    Mahmoud
    0

    Hi Kevin,

    Could you please check this question when you get the chance? There is no way to mention you on that other question, that's why pinged here

    https://our.umbraco.com/forum/using-umbraco-and-getting-started//108974-existing-document-types-templates-are-getting-overridden-after-applying-usync

Please Sign in or register to post replies

Write your reply to:

Draft