Stylizer preview of panel panes doesn't work. When pushing button, the following error is displayed:

* Notice: Trying to get property of non-object in template_preprocess_panels_pane() (line 1165 z /sites/all/modules/panels/panels.module).
* Notice: Trying to get property of non-object in template_preprocess_panels_pane() (line 1198 z /sites/all/modules/panels/panels.module).
* Notice: Trying to get property of non-object in template_preprocess_panels_pane() (line 1199 z /sites/all/modules/panels/panels.module).

Comments

FreeFox’s picture

I have the same problem :(

lifepillar’s picture

Same problem here, using Drupal 7.2, PHP 5.3.6 and PostgreSQL 9.0.4.

To reproduce, visit admin/structure/stylizer/add and simply fill out the forms as follows:

1) write a title and a description, and click Continue;
2) choose “Panel pane” from the pull-down menu, and click Continue;
3) choose the “Plain” basic style, and click Continue;
4) click on Finish.

The warning appears after clicking on Finish. The bug does /not/ occur if the chosen type is “Panel region” or if the basic style is “Rounded shadow box”.

lifepillar’s picture

Just forgot to mention that the style is created anyway, and subsequent modifications seem to be saved correctly (although the warning appears also upon editing an existing style).

ouyang1512’s picture

Same problem here. Anyone knows what's wrong here? Thanks!

chsoney’s picture

Status: Active » Needs review
StatusFileSize
new1.4 KB

Those three lines used coding conventions which assume a variable was an object. I am not sure if it is a problem that the variable is not an object, but this patch should get rid of the warnings.

chsoney’s picture

StatusFileSize
new451 bytes

Looking more closely at the code and where this code is called, this patch appears more appropriate.

chsoney’s picture

StatusFileSize
new557 bytes

Let's try this one last time. Number 6 breaks the view of a panel page because there is no consistency between the use of theme variables. Based on this section of panels_theme:


$theme['panels_pane'] = array(
    'variables' => array('output' => array(), 'pane' => array(), 'display' => array()),
    'path' => drupal_get_path('module', 'panels') . '/templates',
    'template' => 'panels-pane',
);

The variable that they use throughout the mosule ($content) is not part of the panel_pane theme. But $output is only used in panels_stylizer_pane_preview. This time, I changed output to content since that seems to be what every other page uses.

topdawg’s picture

Thank you very much for the patch, it worked.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed and pushed! THanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

globexplorer’s picture

Notice: Trying to get property of non-object in fieldable_panels_panes_preprocess_panels_pane(). The only reason for this error is the lack of an conditional statement including an is_object

This produces the error:

/**
 * Add a class for our bundle to the normal panels pane theme.
 */
function fieldable_panels_panes_preprocess_panels_pane(&$vars) {
  if ($vars['pane']->type == 'fieldable_panels_pane') {
    $entity = fieldable_panels_panes_load_entity($vars['pane']->subtype);
    if ($entity->link && !empty($vars['title'])) {
      $vars['title'] = l($vars['title'], $entity->path);
    }
    $vars['classes_array'][] = 'pane-bundle-' . ctools_cleanstring($entity->bundle, array('lower case' => TRUE));
  }
}

This avoids the error:

/**
 * Add a class for our bundle to the normal panels pane theme.
 */
function fieldable_panels_panes_preprocess_panels_pane(&$vars) {
  if ($vars['pane']->type == 'fieldable_panels_pane') {
    $entity = fieldable_panels_panes_load_entity($vars['pane']->subtype);
    if(is_object($entity)) {
      if ($entity->link && !empty($vars['title'])) {
        $vars['title'] = l($vars['title'], $entity->path);
      }
      $vars['classes_array'][] = 'pane-bundle-' . ctools_cleanstring($entity->bundle, array('lower case' =>   TRUE));
    }
  }
}
globexplorer’s picture

Status: Closed (fixed) » Active
globexplorer’s picture

To avoid erros like these always add a conditional statement:

if (is_object($entity)) {
  //code
}

or for arrays

if (is_array($array_variable)) {
  //code
}
merlinofchaos’s picture

Status: Active » Closed (fixed)

This is an issue about the Panels module. You're talking about code in the fieldable_panels_pane module.

Returning to previous status.