There is a function in Drupal 5 (_phptemplate_variables()
) that has been deprecated in Drupal 6.
Is there a similar function in Drupal 6?
-
2It seems to me that your question title doesn't match with what you explain in the body... Could you please clarify?– acmMar 14, 2011 at 14:15
-
For those of you looking for Equivalent function in D6 and above, look at GoogleTorp's answer.– GoodSp33dApr 1, 2013 at 7:52
4 Answers
well, i'm not totally sure what you mean, but according to the title of the post, you want a redirect function ?
something like the drupal_goto(); function?
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_goto/6
_phptemplate_variables
in D5 have been changed into multiple functions.
The Drupal preprocess functions have changed from Drupal 5 -> Drupal 6, to make them hook based. So instead of having a single function that could be invoked for different hooks, Drupal 6 uses the naming system similar to how hooks is used in modules.
This is described in detail on Drupal.org: Converting 5.x themes to 6.x
_phptemplate_variables()
is not a function that has been deprecated. It is simply a private function that is not used anymore.
Drupal 5 PHPTemplate engine looked for a function with that name to alter the variables used in a template.
function _phptemplate_callback($hook, $variables = array(), $suggestions = array()) {
global $theme_engine;
$variables = array_merge($variables, _phptemplate_default_variables($hook, $variables));
// Allow specified variables to be overridden
$variables_function = '_'. $theme_engine .'_variables';
if (function_exists($variables_function)) {
$variables = array_merge($variables, call_user_func($variables_function, $hook, $variables));
// …
}
// …
}
What the code for Drupal 6 needs to do is to implement MODULE_preprocess(&$variables)
, or MODULE_preprocess_HOOK(&$variables)
(where HOOK
is page
, node
, comment
, or any of the values defined from a theme or module).
function phptemplate_preprocess_page(&$variables) {
if (isset($variables['node'])) {
$variables['template_files'][] = 'page-' . str_replace('_', '-', $variables['node']->type);
}
return $variables;
}
-
1