How can we make an event to trigger when component published from a specific Publication?
-
docs.sdl.com/LiveContent/content/en-US/…– Pankaj GaurSep 15, 2015 at 13:39
-
1Welcome to the site. Just some friendly advice, although you've got an answer below, this question isn't very good quality. Please try to help yourself by doing some research and trying things out first.– Rob Stevenson-LeggettSep 15, 2015 at 14:19
1 Answer
The event handlers (triggers) are system-wise, so you will have to control the publication scope from within the event itself. I would check it at the very beginning, see the example below:
[TcmExtension("YourEventSystem")]
public class YourEvent: TcmExtension
{
public YourEvent()
{
Subscribe();
}
public void Subscribe()
{
EventSystem.Subscribe<RepositoryLocalObject, CheckInEventArgs>(HandlerForInitiated, EventPhases.Initiated);
}
private void HandlerForInitiated(RepositoryLocalObject subject, CheckInEventArgs args, EventPhases phase)
{
//Check for publication id match here
if (subject.OwningRepository.Id != "your_publication_uri")
{
return;
}
//Your logic here...
}
}