Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

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 201 to 241

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   dirname(__FILE__) . "/../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 16th July 2020 00:05 Europe/London time based on the source file dated 17th June 2020 11:52 Europe/London time.