get_template_path()

Description

Returns the path to any template in the system.

Returns the path to any templates in the system as long as they are saved in the correct place:
- /templates (default - base templates)
- /filestore/system/templates (custom templates)
Templates will be structured in folders based on features (e.g templates/contact_sheet/
will be used for any templates used for contact sheets)

Parameters

ColumnTypeDefaultDescription
$template_name string Template names should contain the extension as well (e.g. template_1.php / template_1.html)
$template_namespace string The name by which multiple templates are grouped together

Return

string

Location

include/pdf_functions.php lines 184 to 219

Definition

 
function get_template_path($template_name$template_namespace)
{
    global 
$storagedir;

    
$template_path '';

    
$remove_directory_listings = array('.''..');

    
// Directories that may contain these files
    
$default_tpl_dir   __DIR__ "/../templates/{$template_namespace}";
    
$filestore_tpl_dir "{$storagedir}/system/templates/{$template_namespace}";

    if (!
file_exists($default_tpl_dir)) {
        
trigger_error("ResourceSpace could not find templates folder '{$template_namespace}'");
    }

    
// Get default path
    
$default_tpl_files array_diff(scandir($default_tpl_dir), $remove_directory_listings);
    if (
in_array($template_name$default_tpl_files)) {
        
$template_path "$default_tpl_dir/$template_name";
    }

    
// Get custom template (if any)
    
if (file_exists($filestore_tpl_dir)) {
        
$filestore_tpl_files array_diff(scandir($filestore_tpl_dir), $remove_directory_listings);
        if (
in_array($template_name$filestore_tpl_files)) {
            
$template_path "$filestore_tpl_dir/$template_name";
        }
    }

    if (
'' == $template_path) {
        
trigger_error("ResourceSpace could not find template '{$template_name}'");
    }

    return 
$template_path;
}

This article was last updated 14th July 2025 07:35 Europe/London time based on the source file dated 21st January 2025 15:20 Europe/London time.