Hi guys...
We need to block people from creating new blank pages.
We have templates created for all types of articles, which already apply the correct label and a custom header, however, people end up creating a blank page and are not using the predefined templates.
Is it possible to allow the creation of pages only via template and block the creation of blank pages?
Version: Confluence 7.13.9
Hi @Luana Premoli ,
you can hide the Create button by placing the following to
Confluence Administration → Custom HTML → At the End of HEAD:
<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#quick-create-page-button').hide();
});
</script>
Please note:
Hope that helps!
Kind regards,
Nicolai
Hello @Luana Premoli . Have you tried beating your users until they comply? ;-)
This is a really tough issue to solve. And I have the same issue of creating nice templates, and just have people hit the "c" key to create a blank page.
I assume you only want it in some spaces, so hard to have some solution that works only in some spaces. So you would have to develop a plugin to do what you want, as hiding elements in the menu is not a great solution since there is still a hot key to create a page. Basically have the plugin intercept the Create button and "c" hot key.
All I can suggested is repeated user training, and then find some way to add social shame to people who fail to comply.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Bailey
On our Confluence server the script I referenced in my answer would also map the 'c'-key to start the wizard. I am not sure if you have use cases in mind where this won't work?
You may also provide this script only in the contexts you like. For instance only active on specific spaces.
Cheers,
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My point was that there is no native way to do what she wants -- it requires code work (and admin access) to accomplish. So my assumption is that writing javascript and deploying it is more than the OP is probably will to do.
So cool script, but the vast majority of users don't have the ability and access.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I got it wrong. Thank you for your clarification!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Luana Premoli,
If it is only that you want to remove the button from the user interface, you could do this by adding some JavaScript code to your Confluence instance. You would need administrator privileges to do this.
Since both buttons have a unique identifier, it is quite easy to remove the
In case you do not want to write and integrate JavaScript scripts by yourself, you may want to check out third party apps that allow you to hide elements (such as HideElements for Confluence). Please check if this app meets your requirements.
Cheers,
Robert
Disclaimer: I am one of the authors of the referenced script. It may be used as part of our commercial product Userscripts for Confluence. The script is licensed under the Apache License (see script header) and therefore can be used without our product free of charge.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I made the request to the responsible sector here at the company indicating your .js and their response was the following:
a cursory look at the proposed .js appears to be instance-wide rather than project-specific, at least not without further development which this department does not support.
I don't have enough knowledge to develop the add-on to "filter" by a space.
The space we need to apply this restriction is called LELAS.
Do you have anything that can help us?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Luana Premoli,
You are correct. The code in which context the script should apply needs to be added (or is provided by a third-party-app or some browser logic).
I do not know how the administrators are planning to integrate the script. You may need some support by software developers to implement the software according to your company standards, but to figure out the current space is fairly simple.
This article on confluence.atlassian.com explains how to integrate your script:
<script type="text/javascript">
AJS.toInit(function(){
// Here your code to run
});
</script>
In older versions of Confluence accessing the space key is as simple as this (am not sure if this is still supported on the latest versions, but I cannot find any updated documentation the the Atlassian server:
AJS.params.spaceKey
So the following should work according to the documentation cited above:
AJS.toInit(function(){
if(AJS.params.spaceKey === 'LELAS') {
// Here the code to run on space LELAS
}
});
In case you are dealing with modules (on newer versions of Confluence if AJS.params is not supported on your Confluence instance), you would access the space via the Meta module somewhat like this (I also have the reference for the AJS module in the following snippet in case you need it for your script):
require(['ajs', 'confluence/meta'],
function (AJS, META) {
"use strict";
// Shows only how to access the spece key ...
const currentSpaceKey = Meta.get('space-key');
// Here more of your code
}
Edit: Please note that this code, as simple as it looks, requires maintenance in case the Confluence API changes. Even if the "hide function" of the script of this solution would only take effect on the desired space, it still would run on every page of every space. So for instance, if the API access of AJS.params.spaceKey is removed from Confluence in the future, this code would no longer work and may negatively influence the experience of users.
Hope this helps to get you started.
Cheers,
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your explanations.
Just to confirm, so the code that my confluence admin must inform to remove the default page creation button would look like the link below, correct?
https://pastecry.pt/kxCNwR#DuaDud%3APenFup7At_Ev1Uf7Gux
AJS.toInit(function(){
if(AJS.params.spaceKey === 'LELAS') {
const $quickCreateButton = AJS.$('#quick-create-page-button');
if ($quickCreateButton.length) {
$quickCreateButton.hide();
const $createButton = AJS.$('#create-page-button');
if ($createButton.length) {
$createButton.text("Create ...");
$(document).on('keydown', null, 'c', function () {
$createButton.click();
});
}
}
});
Thanks for yout help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it seems to me that one closing bracket is missing.
I strongly recommend that you check this script in a development environment (see Atlassian SDK) or test environment (probably provided by your admins) before you give it to your Confluence admins. This will help you to spot typos (like the missing bracket) and other issues. Make sure to test it with the version of Confluence you have in production (because of JavaScript modules I mentioned above).
Also be aware that this script needs to be maintained. Make sure that someone is responsible to check that this script works when your admins update Confluence. Maybe this is checked by your admins, but you should be sure. Please keep in mind that this script most likely (depending on how your admins integrate it) runs for each user of Confluence, not only for users of your space.
Maybe you can talk to your Confluence admins and find a solution that ensures now and in the future that the script works as intended?
Be careful. :-)
Cheers,
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Luana Premoli ,
I checked more on this. I see that some users have workaround this problem by using macro Create from Template Macro. On any page, you can include this add-on to ensure that users are creating pages from the template that you specify.
I myself have not tried this but should be achievable.
Thanks,
Srinath T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Luana Premoli ,
Welcome to Atlassian Community.
If you're looking to change the behaviour of the primary Create button, then I am afraid this is not possible. There is a feature request for this below:
You can promote specific templates within individual Spaces. See Promote templates in the Create dialog for more details.
I hope the above info helps. Have a good day!
Thanks,
Srinath T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.