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
Comment | File | Size | Author |
---|---|---|---|
#1 | fpp_rendering-2304921-1.patch | 1.02 KB | plopesc |
Comments
Comment #1
plopescHere is the patch. Using this approach, the HTML output should be the same and would be easy to play with FPP preprocess functions.
Regards.
Comment #2
jwilson3Issue summary cleanup.
Comment #3
jwilson3This seems logical to me. What does a maintainer say? @DamienMcKenna
Comment #5
DamienMcKennaMakes complete sense to me. Thanks plopesc!
Comment #7
Chris Burge CreditAttribution: Chris Burge commented@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.
Comment #8
DamienMcKennaThanks for the prompting, I'm working on a change record: