the culprit is the line checking if templatePath is not null; It adds the page as a candidate in that case. However, it should only add the page as candidate if the template is in the list of templatePaths configured.
Hm, now that I have read the description and text 3x more, I indeed understand the idea of the original implementation. I'm curious what kind of use cases would apply to it.
In our case, we have a template called 'landing page', that basically defines a 'Home'-page (for the actual home of the website, as well as all the sub-sites that we have (they are just specific parts of the website, that contain minor differences that we achieve through CAConfig)).
As such, we want all those pages to be marked as a context root. We thought we could use the RootTemplateContextPathStrategy to achieve this.
With the modification that I did in the pull request, it's working exactly the way we want it to. But then of course the original functionality breaks.
What would be your recommendation in this case? Change the original RootTemplateContextPathStrategy with an option to switch between the original functionality and the functionality in my pull request? Or create an additional ContextPathStrategy?
what about this proposal?
adding a flag "templateMatchAllLevels" that applies the template path matching to all parent pages, or only to the innermost (deepest) - which is the current logic.
example for our use case:
the content folder is structured in regions, country, sites
we match only the templates on the site level
configuration can be applied for each site, or for a whole country or region (whatever template is used there, only the hiearchy level matters)
For the regions / country / sites use-case, we now use the other contextpathstrategy (where we configure level 1, 2), but this might indeed conflict with other websites not using that particular structure.
I think I like your proposal! You can now determine with configuration how you want to let the "Root template" to take effect.
i've merged the feature branch to develop, it's included in the next release.
you can try the snapshot 1.0.7-SNAPSHOT