If you build a view, and use the content row style, and give it a content pane display, panopoly_magic will force you to override the view mode.
It should not do that, and allow NULL to mean stop-messing-with-my-view, not I-want-to-use-default-always.

Basically, when NULL isn't valid, don't use isset().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
FileSize
423 bytes
Pancho’s picture

Project: Panopoly Magic » Panopoly

Moving this to the main Panopoly issue queue.

populist’s picture

Status: Needs review » Fixed

@tim.plunkett - thanks for catching this and this is now committed to dev. accept my apologies on behalf of the craziness that is panopoly magic.

Status: Fixed » Closed (fixed)

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

tim.plunkett’s picture

Component: Code » Magic
Issue summary: View changes
Status: Closed (fixed) » Needs review
FileSize
1.16 KB

Not sure why I thought that fix was enough back in April.

While the previous commit allowed me to fix it in a form_alter, it does not allow regular site users to place a views pane with the view mode they configured. They are still forced to pick one.

I was working around this in one project with:

$form['content_settings']['view_mode']['#default_value'] = '';
$form['content_settings']['view_mode']['#access'] = FALSE;

Which works for my case, but was not what I needed for another site.
We do want to allow editors to pick the view mode, but they should still be able to fall back to "whatever the site built".

---

Sorry for reopening this, I can move it to a new issue if so desired.

redndahead’s picture

Here is a reroll

sylus’s picture

Status: Needs review » Reviewed & tested by the community

Seems to work as advertised :)

mglaman’s picture

Status: Reviewed & tested by the community » Fixed

I'm marking this as fixed. In Panopoly 1.6 it's been refactored to default on the actual value.

Commit: 91b6f026 from #2144021: Panopoly Magic only provides node view modes for view mode selection

  // Get view modes for entity
  $view_modes = panopoly_magic_view_mode_options(panopoly_magic_get_entity_type($form_state['view']));

  $options_default_view_mode = 'teaser';
  if(!array_key_exists($options_default_view_mode, $view_modes)){
    $options_default_view_mode = current(array_keys($view_modes));
  }

  // Add specific style options.
  $form['content_settings']['view_mode'] = array(
    '#type' => 'radios',
    '#options' => $view_modes,
    '#default_value' => $conf['view_mode'] ? $conf['view_mode'] : $options_default_view_mode,
    '#states' => array(
      'visible' => array(
        ':input[name="view_settings"]' => array('value' => 'rendered_entity'),
      ),
    ),
  );
mglaman’s picture

Status: Fixed » Needs work

Actually, there is a larger issue here. I've noticed all Views panes default to displaying the display settings. The options array defaulted to fields regardless my actual settings.

I did find a way to properly read the row settings in the form

  // Determine if this is a fielded view. If so, add magic display type changer
  $view_handler = $form_state['view']->display_handler;
  if ($view_handler->view->style_plugin->row_plugin->plugin_name == 'fields') {

However, this forced $form['content_settings']['view_mode'] to display because of its form state...and the form state relies on the above conditional statement.

Conclusion: I think the display and view mode additions are broken completely - unless I'm missing the bigger picture. Also would we want to allow people to edit view display modes outside of what we provide them via the Views UI?

For example, we let a customer place different panes. They decide "this should be this view type" and then the theme breaks.

mglaman’s picture

Status: Needs work » Needs review
FileSize
3.16 KB

Here is a patch removing the ability to alter a view panes row plugin and its settings. It wasn't working properly and did not respect the actual row plugin being utilized.

dsnopek’s picture

Status: Needs review » Needs work

I'll agree that there are some serious bugs in this! Namely, we shouldn't allow users to change the 'Display type' unless the View's row plugin is fields, and right now, it isn't correctly determining that.

I was actually working on this this morning, when I was reviewing #2160731: Panopoly Magic should respect a view's configured view mode, which has essentially the same complaint as this issue. :-)

The code in that issue doesn't quite work either, and I was trying to see if this would work:

$style_plugin = $form_state['view']->style_plugin;
if ($style_plugin->options['uses_fields']) {
  // The magic!
}

... but that wasn't quite right either. :-/

Anyway, I don't think we should remove this functionality entirely! It's a very commonly used feature of Panopoly and removing it would suddenly break peoples existing configurations.

mglaman’s picture

Sounds good! I didn't think wholesale removal would be a viable option, was more of a "we need to re-work this" gesture. Also if anyone does want to provide wholesale removal, now they have a temp patch ;)

I think you're on right track, but you need to get the style plugin's row plugin name.

$view->style_plugin->row_plugin->plugin_name

The plugin_name equals fields, content, entity, etc. Could check for "is fields or table". Flexslider display formats utilize fields, and I'd be pretty upset if my client could transform an awesome slider into a table of pictures :/ Just a thought.

dsnopek’s picture

Status: Needs work » Closed (duplicate)

Yeah, since we're really working specifically with 'tables' and 'fields' we should probably just check for that. Let's continue this discussion on this issue (since I'm working on the patch there, and this issue already has had a commit in the past): #2160731: Panopoly Magic should respect a view's configured view mode

bkosborne’s picture

Sorry to comment on an old issue, but after reading through the comments, the resolution doesn't quite resolve the original complaint, which is that there's no way to hide the entity view mode selection on the pane settings form. A site admin that created a view pane may only want a specific view mode used, and not allow the site-builder to change it. It seems like giving the end-user this option should be a pane setting in the view, so it can be toggled.

It would be nice if I could even control the view modes exposed to the end-user. I can set some hidden view modes in this variable "panopoly_magic_hidden_view_mode_options", but that applies to all panes, when I'd like to control this per-pane.

I can open a new issue for this if it seems acceptable that this should be fixed?

dsnopek’s picture

@bkosborne: Please open a new issue! You're right that the ultimate resolution was different than the original request, but the history here doesn't really apply to implementing the features that you want, so I think it'd be best to start fresh. Thanks!