Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Notice: Undefined index: responsive_toggle #112

Open
maxplus opened this issue Jul 7, 2014 · 13 comments
Open

Notice: Undefined index: responsive_toggle #112

maxplus opened this issue Jul 7, 2014 · 13 comments
Milestone

Comments

@maxplus
Copy link

maxplus commented Jul 7, 2014

Hi,
i get the following Notice when loading a page that uses a views grid:

Notice: Undefined index: responsive_toggle in kalatheme_preprocess_views_view_grid() (regel 47 van /var/www/vhosts/toporedvps.maxplus.be/httpdocs/sites/all/themes/kalatheme/includes/views.inc).

I have tried to disable responsive toggle in my own subtheme but the notice does not go away.
I'm using:

  • Kalatheme 7.x-3.0
  • Panopoly 7.x-1.2
  • Views 7.x-3.7
@pirog
Copy link
Contributor

pirog commented Jul 8, 2014

@labboy0276 can you check this out?

@pirog pirog added the 7.x-3.x label Jul 8, 2014
@labboy0276
Copy link

@maxplus I would try updating panopoly and see if that helps first

@pirog pirog added this to the 7.x-3.1 milestone Jul 8, 2014
@labboy0276
Copy link

@maxplus Did you try updating your panopoly?

@rokat
Copy link
Contributor

rokat commented Jul 19, 2014

After updating kalatheme .
I had that issue too , re-saving/re-applying the views settings did remove the notice.

@maxplus
Copy link
Author

maxplus commented Jul 21, 2014

Hi,
I'm working an another project with:
Kalatheme 7.x-3.0
Panopoly 7.x-1.6
...and I do not have the same issue there, so I think the Panopoly version was the problem.

But I do have another issue on this new project: #119

@monk-e-chops
Copy link

I'm getting this NOTICE also, Panopoly 7.x-1.10, Kalatheme 7.x-3.0. I tried resaving my views, but this didn't fix anything.

@maxplus
Copy link
Author

maxplus commented Sep 10, 2014

Hi,
I'm running a Drupal 7.31 with Kalatheme 7.x-3.0 not based on Panopoly and I also get this notice.
Using Panels 3.4
I have tried to re-save the view but that does not help.

@maxplus
Copy link
Author

maxplus commented Sep 12, 2014

Hi I did some more testing:

  1. Used the current DEV version of Kalatheme 3: same issue
  2. Edited my view and switched the display mode to HTML list: Notice goes away.
    => when I switch back to the grid mode: Notice comes back...

@dariogcode
Copy link

Same issue here. Also, I noticed some issues with the new views tpl (for grids by example) and the module views_bootstrap that already have his own tpl.

@GuiguiSurLinux
Copy link

Still have this error (7.x-4.x). The error is in includes/views.inc line 47 and 58.

I don't know where responsive toggle is supposed to come from (it's never in options?), but rewriting the code to use empty() instead of "!" will make the error go away. However I'm sure responsive_toggle is supposed to be a thing in the first place, so I don't know that this is a fix. I would submit a pull request but this seems too minor and I don't know what the real fix is, or even what the function does really.

Code:

/**
 * Implements hook_preprocess_views_view_grid().
 */
function kalatheme_preprocess_views_view_grid(&$variables) {
  $variables['gridsize'] = kalatheme_get_grid_size();
  $responsive_tiers = array('xs', 'sm', 'lg');
  foreach ($responsive_tiers as $tier) {
    // A variable is considered empty if it does not exist or if its value equals FALSE
    if (empty($variables['options']['responsive_toggle'])) {
      $variables['options']['columns_' . $tier] = 1;
    }   
    if ($variables['gridsize'] % $variables['options']['columns_' . $tier] === 0) {
      $variables[$tier] = $variables['gridsize'] / $variables['options']['columns_' . $tier];
    }   
    dsm($variables['options']);
  }
  // This is set using the default grid columns value not columns_tier.
  if ($variables['gridsize'] % $variables['options']['columns'] === 0) {
    $variables['md'] = $variables['gridsize'] / $variables['options']['columns'];
    // We need to do ths too.
    // A variable is considered empty if it does not exist or if its value equals FALSE
    if (empty($variables['options']['responsive_toggle'])) {
      $variables['lg'] = $variables['gridsize'] / $variables['options']['columns'];
    }   
  }
}

@GuiguiSurLinux
Copy link

Sorry, didn't mean to unassign, not sure how that happened.

@murraybiscuit
Copy link

The preprocessing function is looking for a var that's supposed to be set in the Kalatheme bs grid Views style override. This isn't being set for two reasons:

  • Kalatheme bootstrap grid isn't overriding the default Grid views plugin.
    Line 31 in kalatheme/includes/views.inc
function kalatheme_views_plugins_alter(&$plugins) {
  if (isset($plugins['style']['grid'])) {
    $plugins['style']['grid']['handler'] = 'views_plugin_style_grid_bootstrap';
    $plugins['style']['grid']['path'] = drupal_get_path('theme', 'kalatheme') . '/views/plugins';
    $plugins['style']['grid']['file'] = 'views_plugin_style_grid_bootstrap.inc';
  }
  $plugins = $plugins;
}

It's being called, but I'm not sure why it's not overriding the default.

  • In the plugin override file itself:
    /views/plugins/views_plugin_style_grid_bootstrap.inc
    This basically just duplicates the current Grid settings, adding a checkbox to reveal BS-specific styles to be set for columns. This page however, doesn't have any defaults for the flag that's being checked in the template function mentioned above.
  function option_definition() {
    $options = parent::option_definition();

    $options['columns'] = array('default' => '4');
    $options['alignment'] = array('default' => 'horizontal');
    $options['fill_single_line'] = array('default' => TRUE, 'bool' => TRUE);
    $options['summary'] = array('default' => '');
    $options['caption'] = array('default' => '');

    return $options;
  }

Is there a reason we can't just extend the default grid rather than using alter to completely override it?

@labboy0276
Copy link

I am seeing this again in 3.1 gonna try and fix this real quick like

labboy0276 pushed a commit that referenced this issue Sep 1, 2015
soniktrooth added a commit that referenced this issue Sep 1, 2015
Kalatheme Issue #112 Fix syntax to prevent Undefined index in views.i…
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants