Hello

Currently, the FPP renders it's $fields content in the preprocess function template_preprocess_fieldable_panels_pane() with this code:

  $vars['fields'] = '';
  foreach ($vars['content'] as $content) {
    $vars['fields'] .= render($content);
  }

and and then prints in the template fieldable-panels-pane.tpl.php using this line: <?php print $fields; ?>

I'm currently altering the markup in my own preprocess hook_preprocess_fieldable_panels_pane(), but have to also worry about *rendering that markup* again in my preprocess.

function mymodule_preprocess_fieldable_panels_pane(&$vars) {
  if ($my_conditions) {
    $vars['content']['my_field'][0]['#markup'] = l($vars['content']['my_field'][0]['#markup'], 'http://drupal.org');
    $vars['fields'] = '';
    foreach ($vars['content'] as $content) {
      $vars['fields'] .= render($content);
    }
  }
}

This is not the standard way to render an entity and it could hit the site performance because FPP content is rendered twice, (once in template_preprocess_fieldable_panels_pane() and then again in mymodule_preprocess_fieldable_panels_pane()).

I propose we remove the $fields string and render the $content variable in the template file, like other entity types do.

What do you think?

Regards

CommentFileSizeAuthor
#1 fpp_rendering-2304921-1.patch1.02 KBplopesc
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plopesc’s picture

Status: Active » Needs review
FileSize
1.02 KB

Here is the patch. Using this approach, the HTML output should be the same and would be easy to play with FPP preprocess functions.

Regards.

jwilson3’s picture

Issue summary: View changes

Issue summary cleanup.

jwilson3’s picture

This seems logical to me. What does a maintainer say? @DamienMcKenna

DamienMcKenna’s picture

Status: Needs review » Fixed

Makes complete sense to me. Thanks plopesc!

Status: Fixed » Closed (fixed)

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

Chris Burge’s picture

@plopesc - This patch greatly improves FPP in terms of theming.

It'd be a good idea to make a bold note in the next release notes regarding this issue. If fieldable-panels-pane.tpl.php is used in a site's theme, then the change in the preprocess function will result in all FPPs rendering as blank until the developer modifies the tpl.php file(s) in the theme.

DamienMcKenna’s picture

Thanks for the prompting, I'm working on a change record: