Download & Extend

Buildmodes not updated when nodes are displayed more than 1 time on the same page

Project:Node displays
Version:6.x-2.x-dev
Component:Code
Category:support request
Priority:major
Assigned:xtfer
Status:closed (fixed)

Issue Summary

Hi all
I probably made a wrong search, but the only issue I could find is this http://drupal.org/node/1316610

I updated to 6.x-2.x, with latest stable release of ds, updated the settings.php file.

I am still having issues when one single node is displayed on more than 1 view with DS on the same page (i.e., "teaser" buildmode for content area and "recent posts" buildmode for footer area)

During the second time , the buildmode is not updated and a node displayed in the content area with "teaser" buildmode is still displayed with the same buildmode in the footer area

Any fix?

Comments

#1

Assigned to:Anonymous» xtfer

No, no fix yet. I had identified this issue on a production site that I'm working on, but hadn't got around to debugging it yet, as I wasn't sure if it was a localised bug or not. Clearly it isn't, so I'll add it to the queue. Expect a fix at some point...

#2

Thanks Xtfer,

just did quick debug.
The bug happens during caching version of DS fields and regions in function nd_build_fields_and_regions(&$node)

line 271 : if (isset($displays[$node->nid])) {

#3

Correct! and also in Display Suite itself somewhere else. I should have patch for this today which fixes it and preserves caching.

#4

Just thought I would post my effort in debugging:

<?php
$node
= node_load(array('nid' => 11384), NULL, TRUE);
$node->build_mode = 'teaser';

$teaser = ($node->build_mode != 'full') ? TRUE : FALSE;
$show_links = ds_show_field('nd', $node->type, $node->build_mode, 'links');

$node = node_view($node, $teaser, FALSE, $show_links);
dpm($node);

$node = node_load(array('nid' => 11384), NULL, TRUE);
$node->build_mode = 'featured_article';

$teaser = ($node->build_mode != 'full') ? TRUE : FALSE;
$show_links = ds_show_field('nd', $node->type, $node->build_mode, 'links');

$node = node_view($node, $teaser, FALSE, $show_links);
dpm($node);
?>

The output rendered the exact same teaser node each time. Not really sure what is going on here.

#5

Display Suite & Node Displays are caching the Display by node ID, not by build mode. Hence, you get the same result every time. Patch coming...

#6

I see, yes the following bypasses the issue although I am sure it has some caching ramifications:

<?php
/**
* Statically cached version of ds_build_fields and regions
*/
function nd_build_fields_and_regions(&$node) {
//  static $displays = array();
//
//  if (isset($displays[$node->nid])) {
//    $node = $displays[$node->nid];
//  }
//  else {
   
ds_build_fields_and_regions($node, 'nd');
   
$displays[$node->nid] = $node;
//  }
}
?>

I will wait for the fix. Thanks for looking at the issue.

#7

The only issue is you lose static caching, which is really only a problem if you reload the node with the same display in two places.

#8

Status:active» fixed

I've committed a fix to dev. If it passes tests tomorrow I'll do a release.

#9

Thanks, it seems to work for me. Good work and nice and simple solution you implemented.

#10

No problem. Thank you.

#11

Status:fixed» closed (fixed)

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

#12

Version:6.x-2.x-dev» 6.x-2.9
Status:closed (fixed)» needs work

I updated drupal core to 6.26 and the problem came again :(

#13

Version:6.x-2.9» 6.x-2.x-dev
Status:needs work» closed (fixed)

@ArielCamino

This issue is fixed and committed, so it is unlikely to be caused by the same issue. Please open a new ticket, with a full description of how to replicate the issue. Thanks.