Is there any other way you can check that the code you want to run on first publsh has already been run ? Can you use a marker property on the node ? otherwise I think you might have to look into the audit trail - just a guess.
arrh yes, how about the BeforePublish event and checking for a publication date (although what happens if item is published, unpublished, and then published again ?)
Yeah, I suppose it's more safe to follow your suggestions Hendy - setting a true/false property and check if it has been set seems more bulletproof :-)
On first published event
Hi,
I'm looking to run some custom code when a node is first published.
I can hook into the NewEventHandler but this isn't useful for me as there is no guarantee that the node will ever be published.
So how can I check if this is the first time the node has been published?
Cheers
Rich
Hi Rich
Maybe you can use the "afterPublish" event? Don't know if you have seen the complete reference of events in the wiki: http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events
/Jan
Hey Jan,
I'm pretty sure that runs everytime the node is published, I just want to run this piece of code once, the first time the node is published.
Cheers
Rich
Hmmm
Wouldn't it be a possibility to check if there has been set a publication date? If it has not been set run the event otherwise don't?
/Jan
Hi Rich,
Is there any other way you can check that the code you want to run on first publsh has already been run ? Can you use a marker property on the node ? otherwise I think you might have to look into the audit trail - just a guess.
Cheers,
Hendy
arrh yes, how about the BeforePublish event and checking for a publication date (although what happens if item is published, unpublished, and then published again ?)
Yeah, I suppose it's more safe to follow your suggestions Hendy - setting a true/false property and check if it has been set seems more bulletproof :-)
/Jan
Yeah there's no event that runs only once, and I think adding one would be be more overhead than benefit.
HI Rich,
Versioning is based on publishing., So when the document has only one version you know it's the first document.
Cheers,
Richard
Hey,
Thanks for the replies, you all rock :)
The code that I run actually sets a value within the current node, so I can just check that every time.
It just felt a little like a little bit of a hack but it works perfect and now I know that there's currently no better way.
Cheers
Rich
is working on a reply...