Quantcast
Channel: Squirrel Hacker » Computer programming
Viewing all articles
Browse latest Browse all 11

Generic hook_theme for drupal 7

$
0
0
<?php
/**
 * Create a themeable item out of all of the templates in the templates folder
 * @implements hook_theme
 * @param array $existing An array of existing implementations that may be used for override purposes. 
 * @param string $type Whether a theme, module, etc. is being processed.
 * @param string $theme the name of the theme (or module apparently)
 * @param string $path the path to the theme or module
 * @return array
 */
function MYModule_theme($existing, $type, $theme, $path) {
    $themes = array();
    foreach(glob($path . '/templates/*.tpl.php') as $f){
	$file = basename($f, '.tpl.php');
	$themes[$theme.'_' . $file] = array(
	    'arguments' => array(),
	    'template' => $file,
	    'path' => $path . '/templates',
	);
    }
    return $themes;
}
?>

flattr this!


Viewing all articles
Browse latest Browse all 11

Trending Articles