-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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