Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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)?
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" />
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.
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:
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.
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.
Yeah it should ignore anything starting with that path.
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?
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.
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.
(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)
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
Is it possible to ignore certain datatypes ?
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.
You're a freeknin rockstar.
Always so quick to reply
So will this work for datatypes as well ?
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.
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
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.
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
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" />
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)
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)
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).
Thanks Kevin, much appreciated!
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
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted