Reputation: 2004
I am adding a new custom table to my Kentico 10 website. I want any custom table structural changes synched, however I do not want data synched between my different environments.
I do have other custom tables though that I want to keep logging staging tasks for.
How do I exclude for a specific custom table? I can see sample: https://docs.kentico.com/k10/custom-development/handling-global-events/excluding-content-from-staging-and-integration
But I don't know what property I can use on the synchronizedObject to validate if its relevant to the custom table.
All the samples I've found so far have been for users/roles which are an out of the box object type.
Upvotes: 0
Views: 402
Reputation: 204
I found this blog post very helpful, https://www.bluemodus.com/blog/october-2016/kentico-tip-how-to-create-a-staging-filter-module
Upvotes: 1
Reputation: 6117
Create a global handler for the log change events of custom table in question. Use something like this:
using CMS;
using CMS.DataEngine;
// Registers the custom module into the system
[assembly: RegisterModule(typeof(CustomHandlerModule))]
public class CustomHandlerModule : Module
{
// Module class constructor, the system registers the module under the name "LogChangeHandlers"
public CustomHandlerModule()
: base("CustomHandlerModule") { }
// Contains initialization code that is executed when the application starts
protected override void OnInit()
{
base.OnInit();
ObjectEvents.LogChange.Before += LogChange_Before;
}
private void LogChange_Before(object sender, LogObjectChangeEventArgs e)
{
// check the type info for your specific custom table type/item.
// Could use a switch statement here too if you have multiple
// make sure to update "namespace" and "classname" with your custom data.
// Do not modify the "customtableitem" string, that is needed.
if (e.Settings.InfoObj.TypeInfo.ObjectType.ToLower() == "customtableitem.namespace.classname")
{
e.Settings.LogStaging = false;
}
}
}
Upvotes: 2