I believe an issue was filed for this a while ago and a different solution was worked out. For those needing to post a block titlelink on a block generated via panels the code is below. I *think* I'm going to add this to the block_titlelink module. Will leave this post up for review for a week or two before deciding.
What concerns me is having to include a bunch of code to maintain compatibility with 3rd party modules. Panels, for instance, doesn't use the standard Drupal hooks for rendering blocks. This, IMHO, isn't an ideal practice as it means modules that use standard drupal hooks for altering output don't work and are forced to include 1-off, module-specific solutions. Would love to hear some feedback on how other module maintainers deal with this issue.
The code is hacky but works:
/**
* This hack provides block titlelink functionality to panels
* TODO: Integrate with block_titlelink module
*/
function mymodule_preprocess_panels_pane(&$vars, &$pane) {
if($vars['pane']->type == "block") {
$subtype = $vars['pane']->subtype;
$bt_delta = 'block_titlelink_' . preg_replace('/\-/', '_', $subtype, 1);
$bt_vars = variable_get($bt_delta);
if(!empty($bt_vars) && !empty($bt_vars['url']) && !empty($bt_vars['display'])) {
$vars['title'] = l($vars['title'], $bt_vars['url'], array('html' => true));
}
}
}
Comments
Comment #1
pruttkay commentedI tried this solution and added this hack to the block_titlelink module. Still no luck to get the title link working in panels. You mentioned that there is also another solution to this problem. I guess the only way to make it work would be copying my theme's block.tpl.php and do it that way. Any advice?
Thanks.
Comment #2
ngmaloney commentedMake sure the hook name is correct. I would actually place this in your theme template.php file and call it MYTHEME_preprocess_panels_pane. That way you won't be running a forked version of a contrib module.
Comment #3
pruttkay commentedThanks for your answer. I was about to reply that it wouldn't work for me, then I flushed caches and that did the trick. Thanks again.
Comment #4
adammaloneI've added this to the documentation for the module here: http://drupal.org/node/1843896
Using the above code in template.php will work for the time being.
Comment #5
llillf commentedHi ngmaloney
Can i know if this also works for Drupal 6.x-2.0? I tried and seems not working
Thanks!
Comment #6
jkingsnorth commentedThis is more of a feature request for tighter support of the panels module. There is a workaround in the documentation for the time being.
Comment #7
anybodyIf someone is interested in creating a patch for this please do. The idea is good but should of course not require to change anything in template.php. We'll have a look at the patch if someone creates it.
Comment #8
cparkner01 commentedI know this thread is on the 7.x version of Drupal, but does anyone know a patch or way of having the title (of a panel block) a URL on Drupal 8?
Comment #9
proteo commentedAfter taking a look at the code in
block_titlelink.module, I think the right approach to tackle this would be to generate the name of the variable from a single point (a function), then allowing other modules to hook into itusing drupal_alter().In this way the solution would be more general and flexible, all you would have to do in order to add support for other modules would be creating a regular alter hook.
If that's OK I'll create a patch ASAP.