silverstripe/silverstripe-framework — pull request #2776 by ryanwachtl (2014-01-13 21:01:33+00:00)
Title: FIX Overriding of theme templates in project folder

Fixes issue of templates not being found when a Page's main/Layout templates are split between the project and theme folders.

This change brings the template overriding inline with the [documentation](http://doc.silverstripe.org/framework/en/topics/theme-development#overriding). According to the documented behavior of overriding CSS and Template files, the `mysite` (or project) folder is searched first and will take priority over files in the theme folder.

However, this currently fails to work when the main and Layout templates are split between the project and theme folders. That is, when a theme contains `Page.ss` and `/Layout/Page.ss` it is not possible to override `/Layout/Page.ss` in your project folder because the candidate template results from the project folder are lost as soon as any `Page.ss` file is found in the theme folder. The reverse occurs when trying to override the main `Page.ss` template in your project folder but there is no `/Layout/Page.ss` in your project.

The code change proposed here will merge the results of the templates found in the project and theme folders (giving priority to project templates) and fix the issues above.