Skip to content

Instantly share code, notes, and snippets.

@nessthehero
Created January 15, 2014 14:11
Show Gist options
  • Save nessthehero/8436935 to your computer and use it in GitHub Desktop.
Save nessthehero/8436935 to your computer and use it in GitHub Desktop.
Drupal template.php file
<?php
/**
* Include our template.whatever.php files
*/
$theme_path = drupal_get_path('theme', 'your_theme');
// Specify the path to our template.php files
// I decided that my template.php files will
// reside in a folder named "php"
$filePath = "$theme_path/php";
// Open the directory
$dir = opendir($filePath);
while ($file = readdir($dir)) {
// require all files that end with a .php extension.
if (preg_match('/\.php/',$file)) {
require_once "$theme_path/php/$file";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment