Adding custom vars with a block I want to use the title of the block as a hyperlink (or maybe adding an image) and I do not know how can I do this.

I've been looking to block.tpl.php. I know I can modify the template the way I want. 

Maybe the way to do it is defining custom variables, such as $block-&gt;mycustom.

If the variable is defined there is a link, if not, nothing. The problem with this approach is that I don't know where this variable should be defined.

Is that correct, or am I totally mistaken?

I am interested in an answer for Drupal 7.
You could add a theme preprocess function for blocks to add some logic pushing variables into your block template. You can then check against those variables to output the title as a link etc.

THEMENAME_preprocess_block(&amp;$vars) {
 //logic here to add variables
}