Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 758 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sitecore publish:end event interaction with user

#1
I have a publish:end event handler, and if there is any errors with it, I would like to show it to the user. Is there any way to do this? Can I hook into something to show messages on the publish end screen (or before anywhere)?
Reply

#2
I don't think you can notify the user directly because `publish:end` is executed on another thread which doesn't know about the Sitecore interface. You can send the user an email.

You can also add the [publishing status content editor warning][1] to let editors know whether the publish completed successfully.

I have installed the publishing status on all the sitecore sites I have worked with and users find it very useful.


[1]:

[To see links please register here]

Reply

#3
Your question intrigued me, because this one of those things that I expect to be possible with Sitecore, but no one really takes the time to find out how.
So I dove into it and I'm pleased to say that it's possible, to a certain end!

In your event handler that is called on `publish:end` you can look up the publish jobs that are currently running.
Once you get the jobs, you can modify its status messages:

var publishJobs = Sitecore.Jobs.JobManager
.GetJobs().Where(x => x.Category.Equals("publish"))
.ToList();

publishJobs.ForEach(x => x.Status.Messages.Add("This is a message inserted by the publish:end event"));

The result will be displayed on the last page of the publication dialog in the Results textbox.

![enter image description here][1]

The thing with the results textarea is that you only see if you click the 'Click here to see additional information' link.

To change that behaviour, you need to modify the dialog XML which is located in `/sitecore/shell/Applications/Dialogs/Publish/Publish.xml`.
In there you can set the result textarea to be always visible.

There is one drawback though: you can't know which job is your publishing job...

Each job has a handle assigned to it which is basically a Guid and some info about the server and site, but in your event handler you don't have this information (*or at least I can't find it*).

I think in most cases it's no problem to simply add the message to all running publish jobs (after checking if it's already there), but it's something to take into account.

Hope this helps!


[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through