Closed (fixed)
Project:
Block Title Link [D7]
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
17 Dec 2009 at 15:46 UTC
Updated:
21 Apr 2010 at 21:00 UTC
Hi Nick,
thx for this simple but very usefull module.
For your information, see the code below to see how I adjust the preprocess_block to support the l() fonction of drupal (who take care of the eventual subdirectory where drupal is installed, etc ...).
I added a class to the a href to be able to style this link in my theme style.css file.
By using $vars['block']->subject, I do not need to adjust the block.php
Regards,
/**
* Implementation of hook_preprocess_block
**/
function block_titlelink_preprocess_block(&$vars, $hook) {
if ($hook == 'block') {
$var_name = $vars['block']->module .'_'. $vars['block']->delta;
//$vars['block']->title_link = _block_titlelink_get_link($vars['block']);
$tmp=_block_titlelink_get_link($vars['block']);
if (trim($tmp)!='') {
$vars['block']->subject = l($vars['block']->subject,$tmp, array('attributes' => array('class' => 'block-title-link')) );
}
}
}
Comments
Comment #1
AlexanderPop commentedThank you. It solved my problem http://drupal.org/node/662314. Now it works.
Comment #2
ngmaloney commented@nico059 Thanks for the code snippet. Would it make sense to integrate your preprocess hook into the module?
Comment #3
danny englanderThank you, this fixed my issue as well. In my case I had a block created from a view. Once I added the code above, all was well!
Comment #4
nevets commentedMinor point but the code can be simplified to
(since its an instance of hook_preprocess_block it already knows its a block)
Comment #5
Ela commentedTo which file do I add this code? :)
Comment #6
nevets commentedThe code would go in your themes template.php file
Comment #7
Ela commentedThank you :)
Comment #8
jmcintyre commentedThe approaches recommended above worked for me, but they broke my site when I disabled the Block Title Link module... why not add this capability into the module itself, rather than relying using a theme hook? Sorry that I don't have CVS access set up yet and can't offer this as a patch. It's an easy fix, though, to the function beginning on line 65 of block_titlelink.module:
Comment #9
jeebsuk commentedIs this liable to be added into a new release of the module at some point soon?
Comment #10
ngmaloney commentedYes. I'll test and add today. Thanks for all the contributions!
Comment #11
ngmaloney commentedI added the code from comment #4 @nevets to the block_titlelink 6.x-1.x-dev release. I could use some help testing.
Thanks again for all the contributions!
Comment #12
jeebsuk commentedI would happily help you test it, but couldn't find where to download the dev version, only the fully released module is listed on the module page
Comment #13
jeebsuk commentedHi,
I got the module. It is not saving the path when I submit the block form with a path specified for the link, if I return to the block edit form the path field is empty.
Comment #14
ngmaloney commented@JeebsUK thanks for the feedback! I'll get that fixed asap.
Comment #15
ngmaloney commented@JeebsUK: I'm not able to replicate using the Head release from CVS. Could you walk me through the steps to replicate the bug?
Comment #16
jeebsuk commentedHi there,
I downloaded the latest release from the view all releases pages and installed it. I tried to set a path of "forum" for the active forum topics block but when the block form is saved it does not save the path and the title is not a link or clickable.
Comment #17
ngmaloney commented@JeebsUK - OK Thanks for the info. I don't think there is a downloadable release from the latest CVS HEAD. I'll go ahead and add one. In the mean time, if you are familiar with CVS you can checkout the latest HEAD release and it should work.
Comment #18
ngmaloney commentedResolved in 6-1.5