2

I'm trying to create a block which would include informations on the displayed node like author picture, name, and points (using Userpoints module), the creation date, and some other infos contained in created fields for certain types of nodes.

The thing is that I want to display this block in my sidebar-second (my theme is based on bartik, except that sidebar-second is included in the <div id="content"></div>).

But I don't manage to use variables available in files like node.tpl.php. For instance, when I try to display the author picture in the block, I write <?php print $user_picture; ?> but nothing appears...

Here's what I created on photoshop and I'd like to translate into Drupal (if it can help, and yes it's in French ^^) :what I want finally

Thks !

EDIT : I'm using D7.

EDIT by nyoz : Ok, so it seems like Multiblock is a good beginning. README.txt says the following :

DEVELOPING MULTIBLOCK-ENABLED BLOCKS: Multiblock should successfully clone any regular block created with the block API. However, if you clone a regular block that implements a hook_block_save or hook_block_configure hook, the custom block settings of one block instance will overwrite the settings of another. To get around this, you can make a block "multiblock enabled." To do this, you should add a 'mb_enabled' key with a value of true in hook_block_info to each multiblock enabled block you are creating. Next, add an optional $edit argument to your hook_block_view and hook_block_configure functions. Once you do this, the instances you create will get the block instance ID passed in the $edit variable for the view, configure, and save $ops. This will let you save and load different data to different instances based on this instance ID. It is passed in with the 'multiblock_delta' key with the following format: $edit['multiblock_delta'] = array( '#type' => 'value', '#value' => $block_id );

Example implementation of hook_block_info: function hook_block_info() {
$blocks['powered-by'] = array( 'info' => t('Powered by Drupal'), 'weight' => '10', 'cache' => DRUPAL_NO_CACHE, 'mb_enabled' => TRUE, ); return $blocks; }

... So, I created a custom module containing :

function hook_block_info() {
  $blocks['content'] = array(
    'cache' => DRUPAL_NO_CACHE,
    'mb_enabled' => TRUE,
  );
  return $blocks;
}

I've also tried $blocks['main'] $page['main'] $page['content'] -with return $page-. BUT NONE OF IT WORKED (the block is still not multiblock enabled when I look in the instances list).

DO YOU HAVE ANY CLUE PLEASE ? Thks!

1 Answer 1

1

Try MultiBlock module.

MultiBlock module solves this problem by allowing you to create multiple Block Instances of already existing blocks. Please read the README for more information.

6
  • Ok, I'll try it immediately ! :) (what do you mean, I didn't upload image, you can't see it ?)
    – nyoz
    Jun 20, 2011 at 19:36
  • Sorry, my mistake.
    – Codium
    Jun 20, 2011 at 19:43
  • Wow... I've read README.txt and try to use it... But I'm completely lost! O_O I created an instance of the main content block, but it just copy the entire content, and I can't overwrite it (I mean select the info to be displayed)... Do you know how to use it please? Is it the multiblock enabling thing mentionned in README.txt??
    – nyoz
    Jun 20, 2011 at 21:04
  • If you want to display part of content of that block, just use CSS to hide other content
    – Codium
    Jun 20, 2011 at 21:32
  • I can't use CSS only as the original and the instance have the same id and classes... Original post edited to add more infos
    – nyoz
    Jun 21, 2011 at 11:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.