Some teasers are shown from view and different views may require different teaser layout. So idea is to pass view name with $node object so panels selection rules may use php code (or maybe later access plugin) to sort out which layout to render. Here is code in my head, I think Ill provide a simple patch later...

  //Set a $node variable to prevent infinite looping
  //Loads full node.  Preprocessor only loads a teaser node.
  $node = node_load($vars['node']->nid);
  $node->panels_teasers = $vars['node']->panels_teasers = TRUE;

  // If node is called from views, add its origin for selection rules.
  if ($vars['node']->view) {
    // This adds view name if node coming from views.
    // Maybe we should add whole views object? Performance? Is it usefull?
    $node->view->name = $vars['node']->view->name;
  }

and then in selection rules you could use

if ($contexts['argument_nid_1']->data->view->name == 'VIEW_NAME_HERE') {
  return TRUE;
}
return FALSE;

Works for me, will write patch when free time.

Comments

henrijs.seso’s picture

Title: pass node origin with $node object » different teaser variant selection depending on view that displays it
Assigned: Unassigned » henrijs.seso
jon pugh’s picture

Status: Active » Closed (won't fix)

Project is no longer supported.

Thanks for your interest!

Please see Display Suite for similar functionality.