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)?
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, 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 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.
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.
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
uSyncIgnore flag on
a. control level (ignore 1 control)
b. section level (ignore a group of controls)
c. page level (ignore a page).
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
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.
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
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.
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
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)
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).
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)?
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.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:
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
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.
K
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.
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 theShouldImport
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
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
a. control level (ignore 1 control)
b. section level (ignore a group of controls)
c. page level (ignore a page). 2
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
Hi guys,
Is it possible to ignore certain datatypes ?
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 theShouldImport
method.something like below would do it.:
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
Shot Kevin,
You're a freeknin rockstar.
Always so quick to reply
So will this work for datatypes as well ?
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
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.
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
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:
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)
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).
Thanks Kevin, much appreciated!
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
is working on a reply...