2

I have added a custom block to my users' profile page that shows a list of all that user's submissions. I would like the title to be the user's name then projects so for the user Mike I would like to see "Mike's Projects" as the block title. Is there a way to do this?

  • This is a good question, I know the easiest way is in a custom module, like Daniel said. Its quite easy and is the usual way one would attack this, but I am curious as to if it can be done on php code through the block admin interface? , I assume one very ugly hack that would work would be simply using hook_block_view_alter with an existing module, thereby 'hijacking the hook for that particular block. Example: function block_block_view_alter() would hijack the use of blocks hook. Still. Dont do this. Good-luck – stefgosselin Feb 2 '12 at 7:04
  • Would any of these help out-of-the-box (or provide a basis for writing your own)? : drupal.org/project/page_title drupal.org/project/auto_nodetitle – therobyouknow Feb 2 '12 at 9:26
5

If you don't like to get dirty with PHP code than you can install Token Filter module, hide the title (add <none> in the title field) and create your title in the content of the block wrapping it in a tag. The new title would be like this: <h2>[user:name]'s Projects</h2>

7

If you're familiar with Drupal's hook system, you can do this via hook_block_view_alter

1

You can do this thing with block.tpl.php in theme .$block->subject

if ($block->module=block && $block->delta='Your block ID' ){
print 'company name' }
else {print $block->subject;}

your block id ==click in config in block section in admin and you can have the block id in url at end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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