There are hundreds of places in my project which contain the following code:
include $root . $template;
Where $root is document root for the relevant part of the CRM and $template is the HTML template file. The $root variable is different for different parts of the CRM.
I want to now make all parts of the CRM use the same template file. I can't simply change $root to the central document root because there are other places in the code which use that variable. I just want to change it for loading the template.
Is there a way to save time, so I don't have to go over all the places in my code where this appears? Is there perhaps a way of making the $template string overwrite the $root string when concatinated?
i.e.
$root="$_SERVER['document_root']."\some_folder";
$template="[something_to_ignore_concatination?]".$_SERVER['document_root']."\template_file";
//So $root.$template = just $template
Warning: What you'll see below is an abomination, do not use this in real software!
Assuming these values:
$_SERVER['document_root'] = 'path/to/root'
$root == $_SERVER['document_root'] . '/some_folder' == 'path/to/root/some_folder'
$template == '/' . $_SERVER['document_root'] . '/file.php' == '/path/to/root/file.php'
$root . $template == 'path/to/root/some_folder/path/to/root/file.php'
You could symlink
path/to/root/some_folder/path/to/root -> path/to/root/
So that the double path still gets resolved.
Note: The paths above should be treated as relative to one of the folders added to the PHP include_path.