Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created May 13, 2019 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/fbbb48d358567363a3d9e0dca54b7f94 to your computer and use it in GitHub Desktop.
Save Pebblo/fbbb48d358567363a3d9e0dca54b7f94 to your computer and use it in GitHub Desktop.
Example of how to filter EE's locate template function to add the path of any custom templates you may have within a custom functions plugin (in a `/templates/` directory). Place your custom template in /plugins/{your_custom_plugin}/templates/
<?php //Please do not include the opening PHP tag if you already have one
add_filter('FHEE__EEH_Template__locate_template__full_template_paths', 'tw_ee_cfp_template_paths', 10, 2);
function tw_ee_cfp_template_paths($template_paths, $file_name){
$custom_template_files = array_map('basename', glob( plugin_dir_path( __FILE__ ) . 'templates/*.php'));
if(in_array($file_name, $custom_template_files)) {
array_unshift($template_paths, plugin_dir_path( __FILE__ ) . 'templates/' . $file_name);
}
return $template_paths;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment