Remove 'Duplicate this page and subpages' functionality in Silverstripe
In Silverstripe if you right click on a page in Sitetree you have the ability to duplicate either a single page or a page and all its children.
We have found that users occasionally duplicate pages with large numbers of children and would like to prevent this by either removing the 'This page and subpages' option or by restricting it to admin users only.
How can this be achieved?
Looking at the code in cms/javascript/CMSMain.Tree.js
in SilverStripe 3.4 it doesn't look like there is currently a way to switch this off.
One option we have is to add some CSS to the CMS to hide the menu item for everybody:
mysite/css/cms.css
#vakata-contextmenu a[rel="duplicate"] + ul > li:last-child {
display: none;
}
To enable the cms.css
file we add the following line to our config.yml
mysite/_config/config.yml
LeftAndMain:
extra_requirements_css:
- 'mysite/css/cms.css'
Adding the following code to page.php prevents non admin users from duplicating pages and subpages. The menu item is still visible which is suboptimal but is good enough as a quick solution.
public function duplicateWithChildren() {
if(!Permission::check('ADMIN')) {
throw new ValidationException("You must be logged in as an Admin to duplicate a page and subpages");
}
return parent::duplicateWithChildren();
}
链接地址: http://www.djcxy.com/p/36046.html
上一篇: 垂直滚动视图与垂直导航冲突