Is there a way to place HTML in a block title. What I'm trying to do is change the color of part of a block title via CSS like so:

Block <span class="red">Title</span>

However when I type that into the "Block Title" box it shows up as "Block <span class="red">Title</span>" instead of just "Block Title" (with "Title" as the color of the CSS class). I changed the input filter to full HTML but apparently that only applies to the body, not the title. Any ideas?

Comments

stephenhendry’s picture

http://drupal.org/node/11813

Is how to edit the block in PHPTemplate. If you need more help post back and I will give a hand
--------------------------------------
http://www.stephenhendry.net

dolphinsdock’s picture

Thanks for the fast response but, if I'm reading it correctly, that doesn't help me as I'm trying to change color within one single block title. For example (using strong instead of a color):

userlogin
myblock
blogroll

However if type those into the the Block Title box I get:

user<strong>login</strong>
my<strong>block</strong>
blog<strong>roll</strong>

Basically, I'm just looking for a way to input HTML into the block title. Anything in the template is probably going to be too general, as each block is different.

stephenhendry’s picture

There may be a nicer way to do this but you could do:

<div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>">
  <div class="content"><?php print $block->content ?></div>
</div>

We now no longer display the block title.
Then in the content of the block enter the title there. If you are using a pre made block you would have to add a custome block with the title inside and use the code found here to display the orginal block content.

http://drupal.org/node/26502

It's a hack but should work
--------------------------------------
http://www.stephenhendry.net

stephenhendry’s picture

The block code would be for new users:

<h2>New <span class="red">User</span></h2>
<?php
$block = module_invoke('user', 'block', 'view', 2);
print $block['content'];
?> 

Make sure you have "Input format: PHP" selected when creating the block.
--------------------------------------
http://www.stephenhendry.net

dolphinsdock’s picture

It's definately a pretty dirty hack, but it works.

Thanks, I would not have figured that one out on my own.

stephenhendry’s picture

Glad it is working. We will probably find out there is a nice way to do it from some one else.
--------------------------------------
http://www.stephenhendry.net

dolphinsdock’s picture

Found a pretty big limitation to this hack that I'd like to get your opinion on.

The user login box. If you put it in as:

<h2>user<span class="gray">login</span></h2>

$block = module_invoke('user', 'block', 'view', 0);
print $block['content'];

The result is that the title remains even after login (when the username and password fields have disappeared). I've flipped through the forums and tried to figure it out on my own but I'm a designer, not a programmer, and I've managed to lock myself out of my own site three times (had to go directly into the database to turn off my custom login block) so I thought perhaps I should ask for help. How can I use the custom title and have the login box function as normal?

Update:
I got it:

<?php
global $user;
if (!$user->uid) : ?>
<h2>user<span class="gray">login</span></h2><BR>
<? 
endif;
$block = module_invoke('user', 'block', 'view', 0);
print $block['content'];
?> 
sepeck’s picture

Now, read my sig and STOP playing with matches on your live site! :) Also, read the left hand link as well.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

dolphinsdock’s picture

Good advice, but not needed for me. My whole site is a test site. I haven't even purchased another domain yet (I have it hosted in a subdirectory of a non-drupal site I own). I'm just taking drupal for a test-drive in hopes of using it for a project I'm contemplating for the near future.