cancel
Showing results for 
Search instead for 
Did you mean: 

Disable create content

adela
Champ in-the-making
Champ in-the-making
Good morning,
I try to disable the button "Create Content" from the repo-toolbar, but the rest of the buttons are disabled too.
Is not posible to disable or hide only one button of the bar?
Thanks!
4 REPLIES 4

arnoldschrijve1
Champ on-the-rise
Champ on-the-rise
You can override the OnReady event of the RepositoryDocListToolbar YUI component that is defined in share/components/documentlibrary/repo-toolbar.js. There are various ways to do this, some more elegant than others.

I would opt to create a modified repo toolbar webscript that creates an MyRepoDocListToolbar instance which is an extension of the original toolbar. (Note that this is not the easiest way to achieve this, but it is a clean way, I think)

These are the steps that are involved:

    - Create a new webscript my-repo-toolbar.get.desc.xml with url '/components/documentlibrary/repo/my-toolbar' (the location of this webscript depends on how you've setup your Share project. It could be in web-extension dir or at the appropriate location in your AMP or JAR project)
    - Create a javascript file my-repo-toolbar.js share/components/documentlibrary
    - Copy the code from the original repo-toolbar.js (which is itself an extension of DocListToolbar) into this file and adapt it. In this case you'll probably only want to override the OnReady event. Be sure to first call OnReady on the super class.
    - Include a reference to this javascript in my-repo-toolbar.get.head.ftl along with the contents of repo-toolbar.get.head.ftl
    - Do the same for my-repo-toolbar.get.html.ftl. Make sure that it instantiates MyRepoDocListToolbar instead
    - Include my-repo-toolbar.get.js with identical content as repo-toolbar.get.js
Hope this helps.

adela
Champ in-the-making
Champ in-the-making
Thank you very much Smiley Happy Very useful information!

jagrutirout1
Champ in-the-making
Champ in-the-making
I have followed the steps.

1)Created a new webscript my-repo-toolbar.get.desc.xml with url '/components/documentlibrary/repo/my-toolbar' .
2)Created a javascript file my-repo-toolbar.js share/components/documentlibrary.
3)Copied the  OnReady event code from the original repo-toolbar.js (which is itself an extension of DocListToolbar) into this file and adapt it. 
4) Included a reference to this javascript in my-repo-toolbar.get.head.ftl along with the contents of repo-toolbar.get.head.ftl.

5)    Included a reference to this javascript in my-repo-toolbar.get.html.ftl along with the contents of repo-toolbar.get.html.ftl by instantiating  MyRepoDocListToolbar.

6)   Included my-repo-toolbar.get.js with identical content as repo-toolbar.get.js.

Restarted the server.But the change did not reflect.Please tell me if I have done any mistake?  where do I need to change in OnReady function.

romschn
Star Collaborator
Star Collaborator
There are two probable ways to hide the "Create Content" button from the document library view.

1. Hide the button from the js file. To do so, please follow below steps.
    Go to components/documentlibrary/toolbar.js
    In onready method, just simply put below line after the definition of YUI create button and once it is pushed to dynamicControls.
    this.widgets.createContent.addClass("hidden");

2. Hide the button from the ftl file itself. To do so, please follow below steps.
    Go to components/documentlibrary/include/toolbar.lib.ftl
    search for createContent-button. It will be defined in a span inside create-content div class.
    Add the  "style="display:none;"" to the div class which holds the div for create-content div.

Hope it helps to achieve what you are looking for.

Thanks,

Do give a point if it was helpful to you.