I want to display a background image inside a block. does anyone know how to display an image inside a block?

Comments

alim418’s picture

you can either use block.tpl.php to theme that

block-module-delta.tpl.php
block-module.tpl.php
block-region.tpl.php
block.tpl.php

ryanbasicind@aol.com’s picture

Ok I understand but I don't want to apply it to all the blocks just one of them.

alexiscott’s picture

The block should have a unique ID in the HTML - something like id="block-something"

In the CSS you should be able to use that such as:
#block-something {
background: url(path_to_you_image);
}

The image could be one you have in your theme, maybe in an images folder so the path might start with images such as url(images/your_image.jpg)

Hope that helps.

Eve42’s picture

Posted by arcX on October 30, 2008 at 7:50pm

The block should have a unique ID in the HTML - something like id="block-something"

In the CSS you should be able to use that such as:
#block-something {
background: url(path_to_you_image);
}

The image could be one you have in your theme, maybe in an images folder so the path might start with images such as url(images/your_image.jpg)

Hope that helps.

I'd like to try this for my top column blocks but can't work out how to do it exactly (I'm using Mayo theme): in the page.tpl.php page the blocks are listed as

<?php print mayo_build_columns( array(
$page['top_column_first'],
$page['top_column_second'],
$page['top_column_third'],
$page['top_column_fourth'],
));

and in template.php there's a function to build the column blocks which includes the current css class ('column-blocks'), but I can't work out how I can make individual classes for the blocks to generate different images for each block. Any help would really be appreciated.

gbrussel’s picture

Give Block Theme a spin.