Developer forum

Forum » Development » Notifications Namespace > NewsV2 Class : ItemCopy

Notifications Namespace > NewsV2 Class : ItemCopy


Reply
Hi,

With the nofications subscriber
"Dynamicweb.Notifications Namespace > NewsV2 Class : ItemSaved Field"
it possible to detect if a news item has been saved.

How can we detect if a news item has been copied? We would like it to be hidden by default.

If there's no nofication we'll have to check the db for news item with the same name and then hide the news item!? Any other suggestions...

/Morten


Replies

 
Reply
 Hi Morten,
 
Notifications.NewsV2.ItemSaved does not sent additional information which operation was performed.
But you could to check request and determine operation type.
 
For example,
 
 
using System;
using Dynamicweb;

namespace CustomModules6.CustomModules.zzz
{
 [Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.NewsV2.ItemSaved)]
 public class NewsV2ItemSavedObserver1 : Dynamicweb.Extensibility.NotificationSubscriber
 {
  public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
  {
   if (args == null)
    return;

   if (!(args is Dynamicweb.NewsV2.Extensibility.NewsItemNotificationArgs))
    return;

   Dynamicweb.NewsV2.Extensibility.NewsItemNotificationArgs news = (Dynamicweb.NewsV2.Extensibility.NewsItemNotificationArgs)args;

   if (Base.ChkBoolean(System.Web.HttpContext.Current.Request["isCopy"]))
   {
    //todo: insert code here
   }
  }
 }
}

//Dmitry

 

You must be logged in to post in the forum