问题
I created a user in sitecore with 2 roles assigned to him i.e author and publisher When this user who is both author and publisher creates any content he shouldn't be able to publish it.
Can i overwrite the publish action? check on the user who submitted the content and the roles he is assigned to and restrict him with a popup message or something like that? Any help is appreciated.
Thanks.
回答1:
Follow the below steps to write custom publish actions
- For customizing the publish action, Write a c# class and inherit
Sitecore.Shell.Applications.Dialogs.Publish.PublishForm.There
are override methods like ActivePageChanged and OnNext. You can
basically overwrite those classes and write your own alerts with
Sitecore.Web.UI.Sheer.SheerResponse like shown below.
SheerResponse.Alert("The current item will not be published.Please select both staging and web database to publish the HOME item."); - Copy the Publish.xml file from (your siteroot/)/sitecore\shell\Applications\Dialogs\Publish.
- Create "sitecore\shell\Override\Applications\Dialogs\publish" in root of website
- Paste publish.xml in the following folder in root of your site "sitecore\shell\Override\Applications\Dialogs\publish"
Open publish.xml file and modify the Wizard tag
CodeBeside="Sitecore.Shell.Applications.Dialogs.Publish.PublishForm,Sitecore.Cli ent"
to
CodeBeside="your Class Name with name space here,your Assembly name"
Here is screenshot of how publishoverride form should look like
来源:https://stackoverflow.com/questions/26475500/how-to-customize-publish-action-sitecore