Active
Project:
Panels
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Jul 2011 at 17:26 UTC
Updated:
26 Apr 2012 at 13:45 UTC
Background: I'm writting a quick port to Panels tabs (here), and when building the tabs, I'd like to get the pane's title. Currently I'm doing this like this:
foreach ($display->panels[$region_id] as $pane_id) {
$pane = $display->content[$pane_id];
$content = ctools_content_render($pane->type, $pane->subtype, $pane->configuration);
$title = !empty($content->title) ? $content->title : t('Tab @delta', array('@delta' => $delta));
// ...
++$delta;
}
Is there a bette way, instead of reinvoking ctools_content_render(), where I can get the pane's title before it's rendered?
Comments
Comment #1
merlinofchaos commentedHm. No, titles are set upon render, not before. There's no way to get a pane's title prior to render. Often its dynamic and based upon what's being rendered.
Comment #2
amitaibu> There's no way to get a pane's title prior to render
Indeed, however in my example theme_panels_tabs_style_render_region() gets the pane _after_ being rendered. So the question is there some (static) cache of the $block variable the pane returned?
Maybe another option would be regex, so I can yank the
.pane-titlefrom the rendered paneComment #3
merlinofchaos commentedHm. It doesn't look like this data is stored for you.
You could implement hook_panels_pane_content_alter() and store the data in a static?
Comment #4
amitaibu> You could implement hook_panels_pane_content_alter() and store the data in a static?
Yap, that did the trick. Module now "yanks" the pane title and uses it as the tab's title. thanks!
Comment #5
merlinofchaos commentedI think the renderer object could easily store this information. Styles should now have access to the renderer object I believe, so it would be pretty easy to do. Right now it only stores the rendered panes, not the unrendered, but there are several styles that need both. And irght now only the pane style gets the unrendered pane. It would be a relatively easy thing to do, and not costly becuase the renderer is destroyed at the end of the rendering process anyway.
Perhaps should move the issue to Panels for that.
Comment #6
amitaibu> Right now it only stores the rendered panes, not the unrendered, but there are several styles that need both
Maybe this can be related to -- #1227952: Convert and encourage content-type plugins to return renderable array . Maybe we can keep just the unrendered content, and let theme functions work on that array. It would be really nice if hook_page_alter() would get as much renderable arrays from Panels as possible.
> Perhaps should move the issue to Panels for that.
Re-assign to correct project.
Comment #7
moonray commentedWould be nice to be able to alter panel pane content further down in the theme layer, rather than having to deal with a rendered piece of data.
For instance, once you're in hook_preprocess() where the $hook is 'page', there's no way to alter pane classes or anything else.
A renderable array instead of pre-rendered markup would facilitate that.