3

My block has id=block-block-10, now i want to add a more link after the title. This is my code in my theme's template.php.

function mytheme_preprocess_block(&$variables) {
  if($variables['block_id'] == 10){
    $variables['block']->subject='<h2>test></h2><span>more</span>';
  }
}

There is no more text on the block's title. What's wrong with my code?

| improve this question | | | | |
  • what is the block_id ? 10 or block-block-10 ? – nonsenz May 21 '11 at 9:14
  • block-block-10 this is the block html id label. – enjoylife May 21 '11 at 9:58
  • Wrong <h2>test> markup? If it's not that.. you can try dsm($variables) with devel and see for yourself what's wrong. (If it's not executing the hook or it's because the if condition produces false) – corbacho May 21 '11 at 10:13
  • i'm asking because of your $variables['block_id'] == 10. – nonsenz May 21 '11 at 10:42
3

The $variables['block_id'] variable is based on the number of blocks in a region (see template_preprocess_block(). If you want this for a specific block, despite what region it is in, you should be checking $variables['block']->delta == 10 instead.

| improve this answer | | | | |

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.