Re: [development] From Michelle: Request to themers.
On 12/16/2007 4:57:26 AM, John Morahan (john.morahan@gmail.com) wrote:
Why not have them rename the original to, say, _phptemplate_variables_original(), and then add a new _phptemplate_variables() that calls the original and adds more stuff to it? That way you get the original's variables no matter how it returns them.
function _phptemplate_variables($hook, $vars) { $vars = array(); if (function_exists('_phptemplate_variables_original')) { $vars = _phptemplate_variables_original($hook, $vars); } if (module_exists('advanced_forum')) { $vars = advanced_forum_addvars($hook, $vars); } return $vars; }
-john
Now that is a _great_ idea! I'll put that down in the readme as an option if they aren't able to do the merge. Thanks! Michelle
On 17/12/2007, Michelle Cox <mcox@charter.net> wrote:
Now that is a _great_ idea! I'll put that down in the readme as an option if they aren't able to do the merge. Thanks!
Michelle
Along similar lines, have you seen this method: http://drupal.org/node/152426 It might be slightly more generic and easy to use for newbies. -- Cheers Anton
On Sunday 16 December 2007, Anton wrote:
On 17/12/2007, Michelle Cox <mcox@charter.net> wrote:
Now that is a _great_ idea! I'll put that down in the readme as an option if they aren't able to do the merge. Thanks!
Michelle
Along similar lines, have you seen this method:
It might be slightly more generic and easy to use for newbies.
Fascinating. I've recently started doing this in my themes: http://drupal.org/node/201587 Many ways to skin this cat, it seems. :-) -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
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: <?php /** * Intercept template variables * * @param $hook * The name of the theme function being executed * @param $vars * A sequential array of variables passed to the theme function. */ function _phptemplate_variables($hook, $vars = array()) { global $user; $vars['user'] = $user; $vars['path'] = base_path() . path_to_theme() .'/'; $vars['admin'] = $user->roles[3] || $user->uid == 1 ? TRUE : FALSE; $vars['moderator'] = $user->roles[4] ? TRUE : FALSE; $vars['editor'] = $user->roles[5] ? TRUE : FALSE; $vars['authenticated'] = $user->uid ? TRUE : FALSE; // Include broad variables for each hook. if (file_exists($vars['directory'] .'/'. $hook .'.vars.php')) { include_once $vars['directory'] .'/'. $hook .'.vars.php'; $function = 'myplay_theme_variables_'. str_replace('-', '_', $hook); $vars = $function($vars); } // Specific variables for node types. if ($hook == 'node') { if (file_exists($vars['directory'] .'/node-'. $vars['node']->type .'.vars.php')) { include_once $vars['directory'] .'/node-'. $vars['node']->type .'.vars.php'; $function = 'myplay_theme_variables_node_'. $vars['node']->type; $vars = $function($vars); } } return $vars; } ?> On Dec 16, 2007 10:35 PM, Larry Garfield <larry@garfieldtech.com> wrote:
On Sunday 16 December 2007, Anton wrote:
On 17/12/2007, Michelle Cox <mcox@charter.net> wrote:
Now that is a _great_ idea! I'll put that down in the readme as an option if they aren't able to do the merge. Thanks!
Michelle
Along similar lines, have you seen this method:
It might be slightly more generic and easy to use for newbies.
Fascinating. I've recently started doing this in my themes:
Many ways to skin this cat, it seems. :-)
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
That seems much better than the other option, as the one John mentioned would seem to overwrite the $vars array rather than append the forum stuff to it. Anton wrote:
On 17/12/2007, Michelle Cox <mcox@charter.net> wrote:
Now that is a _great_ idea! I'll put that down in the readme as an option if they aren't able to do the merge. Thanks!
Michelle
Along similar lines, have you seen this method:
It might be slightly more generic and easy to use for newbies.
-- Cheers Anton
-- Sean Robertson Web Developer NGP Software, Inc. seanr@ngpsoftware.com (202) 686-9330 http://www.ngpsoftware.com
participants (5)
-
Anton -
Jerad Bitner -
Larry Garfield -
Michelle Cox -
Sean Robertson