I have put a background image to the title of the blocks that I am using on the sidebars. However I need to have a new block that I may use in content area which will have no background image in title. How is this possible ?

Comments

Oblivious-1’s picture

Each block is output in a div with a unique id. View source, note the id, and style as needed.

Oblivious-1’s picture

Or you can style divs with the class "block" differently in the main content area from the sidebars. That will work too.

electronicmonkey’s picture

I think I may not have made myself very clear. When i go to the blocks section in admin and create a new block it will be the default block with the background image in title. However this will not do for the content area , and I will want a block that if I place in the content area will not have the background image in title. I don't know how your solution will work for dynamic blocks.

alihammad’s picture

the glass is half full or half empty? Try making several blocks with different backgrounds as you like. In the specific visibility settings of the block choose "Show if the following PHP code returns TRUE". Check for arg(0) and make a block only appear for that arg(0) e.g. call a block the content block and choose it to "show" only when the arg(0) is content, call another block the admin block and choose it to "show" when the arg(0) is admin. Reply if this doesn't work.

Ali Hammad Raza
WordsValley

joachim’s picture

Every block you create in the admin area will have a unique CSS id applied to it.
Use this to change the way it's styled.

electronicmonkey’s picture

where do i find this unique css id for the block ? certainly not in the blocks admin

Oblivious-1’s picture

It's in the HTML source when you view a page. A block is output something like this:

  <div class="block block-menu" id="block-menu-166">
    <h2 class="title">Block Title</h2>
    <div class="content">Block content is here.</div>
  </div>

Use the div id as your css selector, in this example that would be #block-menu-166. You may on occasion have to use div#{whatever} to get everything.

--
Erik

electronicmonkey’s picture

This is what I grabbed from my source for the particular block :

<div class="block block-user" id="block-user-3">
<div id="topblock"></div>
    <h2 class="blocktitle">all that jazz</h2>
 

Now what I had initially done is introduce another div "topblock" inside block.php to accommodate a decorative top border image . All I am trying to do is get "topblock" to display only in sidebars but not in any other position. Am I making more sense now ?

joachim’s picture

Use different block templates by region, as described in the manual page.

Though for a purely decorative border, I'd use CSS with background-image and padding to give it space.

electronicmonkey’s picture

What I have done is create several new blocks for the border and place them where they are needed. It is not an elegant solution but it meets immediate need.

One big problem though is that I cannot get any padding from the content in blocks whatever I do. The content keep running over the side borders..

jnvsor’s picture

www.getfirebug.com

^^^
you need this

electronicmonkey’s picture

I changed my mind after all and did as the manual instructed - created different block templates for each region like block-content.tpl.php , block-footer.tpl.php etc .
Isn't Drupal marvelous ?

WorldFallz’s picture

Just as an FYI you should be able to do this purely with CSS (depending on your theme). I always start with zen, and to select only the blocks in the content area the selector should be something like:

#content-top .block, #content-bottom .block {
[insert block styling here]
}

I've no idea if there's any overhead to many tpl.php files, but philosophically I like to keep things purely css whenever possible. I like to keep tpl.php files to structural or content changes, not style changes (assuming your theme provides enough css classes/ids).

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz