Here's another fun one Nate Haug showed me. Keep your vars separated into .vars.php files and only loads what is needed depending on the hook:<br><br><?php<br>/**<br> * Intercept template variables<br> *<br> * @param $hook
<br> * The name of the theme function being executed<br> * @param $vars<br> * A sequential array of variables passed to the theme function.<br> */<br>function _phptemplate_variables($hook, $vars = array()) {<br> global $user;
<br><br> $vars['user'] = $user;<br> $vars['path'] = base_path() . path_to_theme() .'/';<br> $vars['admin'] = $user->roles[3] || $user->uid == 1 ? TRUE : FALSE;<br> $vars['moderator'] = $user->roles[4] ? TRUE : FALSE;
<br> $vars['editor'] = $user->roles[5] ? TRUE : FALSE;<br> $vars['authenticated'] = $user->uid ? TRUE : FALSE;<br><br> // Include broad variables for each hook.<br> if (file_exists($vars['directory'] .'/'. $hook .'.vars.php')) {
<br> include_once $vars['directory'] .'/'. $hook .'.vars.php';<br> $function = 'myplay_theme_variables_'. str_replace('-', '_', $hook);<br> $vars = $function($vars);
<br> }<br><br> // Specific variables for node types.<br> if ($hook == 'node') {<br> if (file_exists($vars['directory'] .'/node-'. $vars['node']->type .'.vars.php')) {<br> include_once $vars['directory'] .'/node-'. $vars['node']->type .'.vars.php';
<br> $function = 'myplay_theme_variables_node_'. $vars['node']->type;<br> $vars = $function($vars);<br> }<br> }<br><br> return $vars;<br>}<br>?><br><br><div class="gmail_quote">On Dec 16, 2007 10:35 PM, Larry Garfield <
<a href="mailto:larry@garfieldtech.com">larry@garfieldtech.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div>
<div class="Wj3C7c">On Sunday 16 December 2007, Anton wrote:<br>> On 17/12/2007, Michelle Cox <<a href="mailto:mcox@charter.net">mcox@charter.net</a>> wrote:<br>> > Now that is a _great_ idea! I'll put that down in the readme as an option
<br>> > if they aren't able to do the merge. Thanks!<br>> ><br>> > Michelle<br>><br>> Along similar lines, have you seen this method:<br>><br>> <a href="http://drupal.org/node/152426" target="_blank">
http://drupal.org/node/152426</a><br>><br>> It might be slightly more generic and easy to use for newbies.<br><br></div></div>Fascinating. I've recently started doing this in my themes:<br><br><a href="http://drupal.org/node/201587" target="_blank">
http://drupal.org/node/201587</a><br><br>Many ways to skin this cat, it seems. :-)<br><br>--<br>Larry Garfield AIM: LOLG42<br><a href="mailto:larry@garfieldtech.com">larry@garfieldtech.com</a> ICQ: 6817012
<br><br>"If nature has made any one thing less susceptible than all others of<br>exclusive property, it is the action of the thinking power called an idea,<br>which an individual may exclusively possess as long as he keeps it to
<br>himself; but the moment it is divulged, it forces itself into the possession<br>of every one, and the receiver cannot dispossess himself of it." -- Thomas<br>Jefferson<br></blockquote></div><br>