Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

enter image description here

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?

like image 225
jamckp Avatar asked Aug 29 '16 04:08

jamckp


1 Answers

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'
like image 116
3dgoo Avatar answered Nov 11 '22 15:11

3dgoo