c# - CreateMediaWithIdentity/CreateContentWithIdentity without raising events in Umbraco -
i using umbraco 7 , have written custom code on following events
umbraco.core.services.mediaservice.saved += new umbraco.core.events.typedeventhandler<imediaservice, umbraco.core.events.saveeventargs<imedia>>(mediaservice_published); umbraco.core.services.contentservice.saved += new umbraco.core.events.typedeventhandler<icontentservice, umbraco.core.events.saveeventargs<icontent>>(contentservice_published);
for content, generating media folder , vice versa.
the following code causes other method fired.
var newcontent = contentservice.createcontentwithidentity(mediaitem.name, obj.id, "somecontentalias");
and...
var newmedia = mediaservice.createmediawithidentity(contentitem.name, obj.id, "somemediaalias");
i have used save method update nodes before, , has parameter of raised events...
contentservice.save(contentitem, 0, false);
is there way can create new media item identity , suppress event being raised?
no, not possible. see createmediawithidentity.
of course didn't suppress raising events creating new content (see createcontentwithidentity, suppressed events saving content item. can media item in same way, setting raiseevents
false:
mediaservice.save(newmedia, 0, false);
Comments
Post a Comment