hi

after i have inserted the node_style_return_vars line into my template.php the $vars set with $region vars are lost. check out the following example i'm using:

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) {
    case 'page':

      // Load region content assigned via drupal_set_content().
      foreach (array('example_region1','example_region2') as $region) {
        $variables[$region] = drupal_get_content($region);
      }
      break;
  }

  // node_style module is installed and active
  if (function_exists('node_style_return_vars')) {
    return node_style_return_vars($hook, $vars);
  }
  else {
    return $vars;
  }
}

it looks like there are some variables naming bugs in the node_style_return_vars function. I have corrected them and the following fixes this bugs:

/**
 * Returns a PHPTemplate variables array based on $hook. Called from node_style.inc.
 *
 * @see _phptemplate_variables
 */
function node_style_return_vars($hook, $vars = array()) {
  global $node_style;

  $scheme = $node_style['variables'];
  if (isset($vars['node']) && isset($scheme['display'][$hook])) {
    foreach ($scheme['display'][$hook] as $var) {
      $vars[$var] = '';
    }
  }
  if ($hook == 'page') {
    // Rather than appending to "head", append to styles, thereby allowing for
    // overrides of existing stylesheets.
    $vars['styles'] = $vars['styles'] . trim($scheme['misc']['head']);
  }

  return $vars;
}

here are the diffs:

@@ -322 +322 @@
-function node_style_return_vars($hook, $variables) {
+function node_style_return_vars($hook, $vars = array()) {
@@ -325,2 +324,0 @@
-  $vars = array();
-
@@ -328 +326 @@
-  if (isset($variables['node']) && isset($scheme['display'][$hook])) {
+  if (isset($vars['node']) && isset($scheme['display'][$hook])) {
@@ -336 +334 @@
-    $vars['styles'] = $variables['styles'] . trim($scheme['misc']['head']);
+    $vars['styles'] = $vars['styles'] . trim($scheme['misc']['head']);

are you able to fix this soon, please?

CommentFileSizeAuthor
#3 Bug99760-HEAD.patch1.01 KBhass
#2 Bug99760-4.7.x-1.x-dev.patch1.01 KBhass

Comments

hass’s picture

Are you able to fix this Bug and release a new version? I'd like to remove the hotfix from my website...

hass’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new1.01 KB
hass’s picture

Version: 4.7.x-1.x-dev » master
StatusFileSize
new1.01 KB
Zen’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD with minor modifications. Please test and reopen issue if necessary.

Thanks mate.
-K

Anonymous’s picture

Status: Fixed » Closed (fixed)