You can do that (alert) without a GUI extension, simply by using Event System (OnComponentSavePre event). The GUI extension framework is very different in 2011 and 2013, I would not recommend doing a real extension for 2009, as you would have to rebuild it once you upgrade.
Creating a Tridion 2009 Event System is not as simple as 2011 or 2013, but definitely simpler than GUI extensions.
You need to:
- Create a new "Class Assembly" project in Visual Studio
- Make sure you're compiling for .NET 2.0 or 3.5 (not 4)
- Add references to
Tridion.ContentManager.Interop.cm_tom.dll
, Tridion.ContentManager.Interop.cm_defines.dll
and Tridion.ContentManager.Interop.msxml4.dll
(you will find these files under Tridion\bin\PIA)
- Write code along the following lines:
using System;
using System.Xml;
using Tridion.ContentManager.Interop.TDSDefines;
using Tridion.ContentManager.Interop.TDS;
using Tridion.ContentManager.Interop.msxml4;
namespace yourNamespace.goes.here
{
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ProgId("TDSEvents.Events")]
public sealed class Events : ITCMEvents
- At this point Visual Studio will propose that you press TAB and it will create all the methods for you.
You will then want to find the Identity property and change it from:
public string Identity
{
set { throw new Exception("The method or operation is not implemented."); }
}
to
private string _identity;
public string Identity
{
get {return _identity;}
set {identity = value;}
}
Then you'll search for OnComponentSavePre, and start implementing the logic to read through the fields of your components - whenever you find conditions that are not OK, use throw new Exception("Content of field X is wrong");
. Users will see the text of the exception on their screens and will not be able to save.
You then need to tell Tridion that you have custom code for a specific event - you do that by opening the Tridion Content Manager snap-in, find the Event Configuration node, then finding Component -> Event triggered before saving a component. Change that value from 0 to 1.
Once you're done with that, you'll need deploy this assembly on your servers using regasm
. Google is your friend there.
Last, very important point.
Events like these get triggered on every save of every component. Your code should quickly decide if it needs to execute based on information like schema.Title, and exit as soon as it realizes it has nothing to do. Do make sure you know what you're trying to achieve before you start.
If you have access to the old forum, check this thread for more details.
PS: the same process for Tridion 2011 and higher is somewhat shown here. It's a lot simpler...