Fix for Panels content type render first patch

  1. Index: includes/display-render.inc
  2. ===================================================================
  3. RCS file: /cvs/drupal-contrib/contributions/modules/panels/includes/display-render.inc,v
  4. retrieving revision 1.5.2.17
  5. diff -u -5 -p -u -p -r1.5.2.17 display-render.inc
  6. --- includes/display-render.inc 16 Mar 2010 17:58:33 -0000      1.5.2.17
  7. +++ includes/display-render.inc 27 May 2010 08:20:17 -0000
  8. @@ -111,37 +111,51 @@ function panels_render_panes(&$display)
  9.    ctools_include('content');
  10.  
  11.    $keywords = array();
  12.  
  13.    // First, render all the panes into little boxes. We do this here because
  14. -  // some panes request to be rendered after other panes (primarily so they
  15. -  // can do the leftovers of forms).
  16. +  // some panes request to be rendered after or before other panes (primarily so
  17. +  // they can do the leftovers of forms, or do some early processing that other
  18. +  // panes rely on).
  19.    $panes = array();
  20.    $later = array();
  21. +  $last = array();
  22.  
  23.    foreach ((array) $display->content as $pid => $pane) {
  24.      $pane->shown = !empty($pane->shown); // guarantee this field exists.
  25.      // If the user can't see this pane, do not render it.
  26.      if (!$pane->shown || !panels_pane_access($pane, $display)) {
  27.        continue;
  28.      }
  29.  
  30. -    // If this pane wants to render last, add it to the $later array.
  31.      $content_type = ctools_get_content_type($pane->type);
  32.  
  33. -    if (!empty($content_type['render last'])) {
  34. -      $later[$pid] = $pane;
  35. +    // If this pane is not set to be rendered first, move it to corresponding
  36. +    // array for rendering it, either $later or $last.
  37. +    if (empty($content_type['render first'])) {
  38. +      if (!empty($content_type['render last'])) {
  39. +        $last[$pid] = $pane;
  40. +      }
  41. +      else {
  42. +        $later[$pid] = $pane;
  43. +      }
  44.        continue;
  45.      }
  46.  
  47.      $panes[$pid] = panels_render_pane_content($display, $pane, $keywords);
  48.    }
  49.  
  50. +  // Render panes not set to be rendered first or last.
  51.    foreach ($later as $pid => $pane) {
  52.      $panes[$pid] = panels_render_pane_content($display, $pane, $keywords);
  53.    }
  54.  
  55. +  // Render panes that want to be rendered last.
  56. +  foreach ($last as $pid => $pane) {
  57. +    $panes[$pid] = panels_render_pane_content($display, $pane, $keywords);
  58. +  }
  59. +
  60.    // Loop through all panels, put all panes that belong to the current panel
  61.    // in an array, then render the panel. Primarily this ensures that the
  62.    // panes are in the proper order.
  63.    $content = array();
  64.    foreach ($display->panels as $panel_name => $pids) {

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.