Posted: December 14, 2015 at 7:26 am
|
Hi, |
Hi there, It depends on how the call to locate_template() is made, in the example given
What will happen is locate_template() will add that absolute path to the first element of the array that EE checks for custom files, once the file has been found it skips all of the other checks so in this example thank-you-page-registration-details.template.php will always load from the original location. However, we have altered the way in which locate_template() works to allow for custom templates to load for all calls, we are currently testing those changes to confirm no new bugs have been introduced and will then include those changes within an update. |
|
|
Hi Tony, |
Hi Eduardo, It shouldn’t be long as we’re trying to finish up on testing. If you’d like, you can check out the same branch we are testing here: https://github.com/eventespresso/event-espresso-core/tree/BUG-8013-locate-template |
|
The fix for EEH_Template::locate_template was included in the update that was released today. |
|
|
Perfect, thank you Josh! Eduardo |
Please let us know if you have any problems 🙂 The changes alter the behavior for templates that could not be overridden previously, they will check the sites current theme folder first so can be overridden using that location. |
|
|
Thank you Tony, Eduardo |
I believe so yes. EE_Template_Layout should all run the template through locate_template(), they will all be using absolute paths but with the new changes you should be able to override them. |
|
|
Hmm so I think there’s an error with the file registration_page_wrapper.template.php . Debugging a bit I saw that you’re using get_template_directory() (line 266), but this function retrieve the parent theme directory; if a user wants to override a file including it in a child theme, he can’t. I think that it’s better to search in both places. (you can use the get_sylesheet_directory() function for child theme). Another thing I see is that there’s a filter (FHEE__EEH_Template__locate_template__template_folder_paths) to change the path list, but the path list is modified (theme path and original filepath added) after the filter, so the user doesn’t really have the ability to change the path list. Eduardo |
FHEE__EEH_Template__locate_template__template_folder_paths can be used to add additional paths to search but again it depends on which template file.
That only happens with templates using an absolute path, the theme is checked for the template file, then the absolute path that was passed to the locate_template() call is used. You can still load custom versions of the file from within your theme (although I do agree with your point about using get_stylesheet_directory() for child themes) You can also use ‘FHEE__EEH_Template__locate_template__full_template_paths’ to alter the template paths after all changes have been made. There’s a little extra work involved as you need to use basename() to grab the template filename from one of the paths, then add another full custom path to the array in whichever order you prefer. |
|
|
Thanks Tony for your fast reply. Eduardo |
We won’t be adding a different way to include custom template paths in the near future locate_template allows for custom versions to load, however I have created a ticket to use get_stylesheet_directory() so that templates locate checks the child theme. I’ll check in with developers to confirm this and update this thread shortly. |
|
|
So, in future too, for files passed with full filepath will be impossible to add custom path with FHEE__EEH_Template__locate_template__template_folder_paths, right? |
I can’t say 100% that we will not modify that function, but currently we have no plans to alter how templates using absolute paths are overridden. You can load custom templates by placing the custom template (with the same name) within your theme root directory. So currently if you want to load custom templates within a different directory than root you can use a function like this:
That will load from your child theme within the /content/espresso/ directory. |
|
|
ok, thank you Tony! Eduardo |
You’re most welcome 🙂 Please let us know if you have any further questions. |
|
The support post ‘BUG REPORT: EEH_Template::locate_template doesn't locate templates correctly’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.