I've just started a site based on 4.9.0. I want to cancel the publish event if certain conditions arent met. My code is pretty straight forward:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using umbraco.BusinessLogic;
/// <summary>
/// Summary description for Global
/// </summary>
public class Global : umbraco.BusinessLogic.ApplicationBase
{
bool _beforePublishEventAttached;
public Global()
{
if (!_beforePublishEventAttached)
{
umbraco.cms.businesslogic.web.Document.BeforePublish += new umbraco.cms.businesslogic.web.Document.PublishEventHandler(Document_BeforePublish);
}
}
void Document_BeforePublish(umbraco.cms.businesslogic.web.Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
{
if (sender.getProperty("showCallToAction") != null)
{
e.Cancel = true;
}
_beforePublishEventAttached = true;
}
}
I have two questions/problems:
1) I thought that 4.8 included a method for returning a friendly error/warning message instead of the standard "Error - cancelled by 3rd party..." http://issues.umbraco.org/issue/U4-84. But I can't find any documentation that explains how this can be done, the API still only seems to have a Cancel property.
2) The code above does cancel the publish (I can confirm by going to the public url for the page and checking whether the updates have been published), but it also throws a Js error and prevents the umbraco UI from re-loading, seen below. Either my code is wrong, or there is some form of bug....any ideas anyone?
Just back on the project. Can I just check whether anyone has had this same problem? Im starting to suspect its some sort of deodgy install from version 4.9.
Any news regarding this issue? I see that you created a bug for this a week ago, but has it been solved until now?
I haven't notice this bug until today, but now I have a big problem with this issue because the website that I upgraded to the latest "stable" version 4.9 doesn't work correctly now. If I knew for this issue I wouldn't make the upgrade.
No no news yet, not even recognition of the bug. It's a real dissapointment to be honest, this Agile approach to development and relases has fallen over so soon!
I've just found where the problem comes from. To solve this issue you should:
download the Umbraco 4.9 source code
open file: \src\Umbraco.Web\umbraco.presentation\umbraco\editContent.aspx.cs
go to the line 330
there's missing "speachBubbles" for area parameter, so that line should be replaced with: ClientTools.ShowSpeechBubble(speechBubbleIcon.error, ui.Text("error"), ui.Text("speechBubbles", "contentPublishedFailedByEvent", null));
build the project
I hope this bug will be fixed with the next release, but until then you can manually change the source code and use that new version of the umbraco.dll.
I've submitted a patch for this via Codeplex. I've also made the core team aware of this issue.
@higgsy - I don't think you are being fair in your criticism here - a re-ordering of a language file caused this - very obscure and hard to have detected in testing.
Also http://issues.umbraco.org/issue/U4-84 was a fix which changed the severity of the message from an error to a warning. At present you still can't control the text of the speech bubble.
Cancelling Publish event in 4.9
Hello,
I've just started a site based on 4.9.0. I want to cancel the publish event if certain conditions arent met. My code is pretty straight forward:
I have two questions/problems:
1) I thought that 4.8 included a method for returning a friendly error/warning message instead of the standard "Error - cancelled by 3rd party..." http://issues.umbraco.org/issue/U4-84. But I can't find any documentation that explains how this can be done, the API still only seems to have a Cancel property.
2) The code above does cancel the publish (I can confirm by going to the public url for the page and checking whether the updates have been published), but it also throws a Js error and prevents the umbraco UI from re-loading, seen below. Either my code is wrong, or there is some form of bug....any ideas anyone?
Thanks in advance
Al
Hi all,
Just back on the project. Can I just check whether anyone has had this same problem? Im starting to suspect its some sort of deodgy install from version 4.9.
Any thoughts anyone?
Thanks
Al
I've created a bug for this: http://issues.umbraco.org/issue/U4-889
What a shame, as I now need to port my work across to 4.8.1 and miss out on the great updates in 4.9.0!
Hello,
Any news regarding this issue? I see that you created a bug for this a week ago, but has it been solved until now?
I haven't notice this bug until today, but now I have a big problem with this issue because the website that I upgraded to the latest "stable" version 4.9 doesn't work correctly now. If I knew for this issue I wouldn't make the upgrade.
Thanks,
Dejan
No no news yet, not even recognition of the bug. It's a real dissapointment to be honest, this Agile approach to development and relases has fallen over so soon!
Hello again,
I've just found where the problem comes from. To solve this issue you should:
I hope this bug will be fixed with the next release, but until then you can manually change the source code and use that new version of the umbraco.dll.
Regards,
Dejan
I've submitted a patch for this via Codeplex. I've also made the core team aware of this issue.
@higgsy - I don't think you are being fair in your criticism here - a re-ordering of a language file caused this - very obscure and hard to have detected in testing.
Also http://issues.umbraco.org/issue/U4-84 was a fix which changed the severity of the message from an error to a warning. At present you still can't control the text of the speech bubble.
@Dejan - if you had made the fix it is really easy to submit it to the core: http://umbraco.codeplex.com/SourceControl/UploadPatch.aspx
Have commited changeset f3a3bdaf6329 in 4.10 that fixes that issue. Have updated http://issues.umbraco.org/issue/U4-889 accordingly.
is working on a reply...