Template Priority / Default Selection behaviour

Hello all,

I’ve been trying to use the Template Provider Creation Restriction property to set the default template for a specific space based on the description provided here.

By my understanding the below configuration should set the Wiki Article template as the default for the Knowledge Base Space, however the Diagram template always takes priority.


Have I understood the concept of specificity correctly? Is there a better way to achieve what I want?

Hi Ben,

The relevant code is here. The selected template is:

  • the one specified on the request or
  • the first recommended template for the current location or
  • the blank page

In your case I think you have multiple recommended templates for the “Knowledge Base” location, Diagram template being the first.

Thanks Marius.

OK, I’d understood specificity to mean the one that matches most exactly (compared with other options) to the location. i.e. The Wiki Article template would take priority because it has a 50% “match” as opposed to the 25% “match” of the diagram template.

I think I can move some code around in that template file to change the default.

By the way, I remember you once told another user how to hide/disable the blank page option, but I can’t find the post. Can you point me to it?

Ben

If you’re referring to Restrict "create page" to templates and hide "blank page" then I didn’t answer. You should be able to hide the blank page option using CSS, by hiding the first “category”:

form#create .xwiki-select-options > ul > li:first-child {
  display: none;
}

Thanks, I’ll give that a try!

For others who might find this useful, a small adjustment to the above is required:

form#create .xwiki-select-options > ul > li:first-child > ul > li:first-child {
  display: none;
}