TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,989
  • Total Topics: 21,322
  • Online today: 742
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 419
  • Total: 419

Different Block use different backgrounds?

Started by Gararion, December 18, 2006, 02:14:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gararion

Is it possible to have certain block use a different background?



All of my blocks use that style, but I want certain block to use a gold color background instead.  Is this possible and if so, how would one do it?  I already have the gold background.

*Note: Part I want gold is the dark grey noise effect.  I want to turn that to a gold noise effect.

JPDeni

Yes, it is possible. You would need to alter TPortalBlocks.template.php.

The block background is set in the following lines:


  echo '
  <div', (($theme || $block['frame']=='frame') ? ' class="windowbg"' : ''), ' style="padding:' , (($theme || $block['frame']=='frame') ? '4' : '0') , 'px; ', (isset($context['TPortal']['upshrinkblocks'][$block['id']]) && $context['TPortal']['upshrinkblocks'][$block['id']]==0) ? 'display: none;' : ''  , '" id="block'.$block['id'].'">';


Let's say that you want your searchbox to have a different background. There are three windowbg formats defined in the default style.css file. Define windowbg2 to have your gold background. Then, instead of the code above, you can use:


if ($block['type'] == 'searchbox')
{
  echo '
  <div', (($theme || $block['frame']=='frame') ? ' class="windowbg2"' : ''), ' style="padding:' , (($theme || $block['frame']=='frame') ? '4' : '0') , 'px; ', (isset($context['TPortal']['upshrinkblocks'][$block['id']]) && $context['TPortal']['upshrinkblocks'][$block['id']]==0) ? 'display: none;' : ''  , '" id="block'.$block['id'].'">';
}
else
{
  echo '
  <div', (($theme || $block['frame']=='frame') ? ' class="windowbg"' : ''), ' style="padding:' , (($theme || $block['frame']=='frame') ? '4' : '0') , 'px; ', (isset($context['TPortal']['upshrinkblocks'][$block['id']]) && $context['TPortal']['upshrinkblocks'][$block['id']]==0) ? 'display: none;' : ''  , '" id="block'.$block['id'].'">';
}


Of course, you can use windowbg3 or you can create another windowbg definition in your style.css file and use that.

Nokonium

The idea of being able to set style characteristics for a block is quite a good one. With all 'freestyle' blocks this has always been possible, but not with preformatted blocks.

Thurnok

Well, you can also get away with something that was discussed awhile back.  Take a look at this post here.

Its at least a work-around if you don't want to modify files and such.
Thurnok
The one, the only!

Nokonium

You probably don't even need a table, echo' and a <div> would probably work OK.

I've thought about this a bit more and wonder if it could be made part of the block options along with:

Use frame from theme
Use frame, but not title
Use just the title
Do not use title/frame
Background color
(if blank theme default will be used)

Hack

This is pretty much exactly what I have done on my site regarding the block background code part (I changed 'windowbg' to 'blockwindowbg'. However, i have set my background to be quite dark and I now have a problem in that the text in the blocks is getting lost within the dark background.

Is there a way via the css to make any text in the blocks between the div with the 'blockwindowbg' set to a specific colour instead of being black. (I tried descendants in the CSS but can't quite work it out how to use it..)

(apologies for posting this here but my earlier post did not make that much sense I feel)

This website is proudly hosted on Crocweb Cloud Website Hosting.