Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After reading a lot of posts here about that issue i quickly implemented hook block (because im not into custom hacking into my templates and stuff). It may not be the best solution but i let you decide.
I could not really find out what the: theme_tweetbutton_display($entity, $options = array()
expects as $entity as you could input a whole node via node_load(1) or just an url as i did. some inline doc would be nice on what to pass this function.
/**
* Implementation of hook_block()
*/
function tweetbutton_block($op='list', $delta=0, $edit=array()) {
global $base_url;
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Tweet Button'); //Blockname on Block Page
return $blocks;
case 'view':
$blocks['subject'] = t('Tweet Button'); //Title of Block
$blocks['content'] = theme('tweetbutton_display', NULL, array('url' => $base_url . base_path() . $_GET['q'], 'text' => drupal_get_title() ));
return $blocks;
case 'configure':
return $form;
case 'save':
}
}
Comment | File | Size | Author |
---|---|---|---|
#1 | patch_tweetbutton-6.x-1.4_hook_block.patch | 1.56 KB | michaelfillier |
Comments
Comment #1
michaelfillier CreditAttribution: michaelfillier commentedI implemented blocks in a recent site. I created a block for each display mode. The setup uses aliased urls, not sure if there will be any conflict without it.
I attached a patch (first one so let me know if it works fine)
Comment #2
Jukebox CreditAttribution: Jukebox commentedThanks for the patch michaelfillier.
The only issue I had was that the blocks didn't seem to get cached correctly. Not entirely sure why. They would appear after I cleared the cache, but after a 2nd manual refresh, the block had lost its theming and inner html.
Following this post, I was able to correct this issue and make the block show correctly. I issued the following mysql command:
UPDATE blocks SET cache=-1 WHERE module='tweetbutton';
I'm sure there's a better solution out there, so this is just a temporary fix.