TinyPortal

Development => Block Codes => Topic started by: Gararion on December 18, 2006, 02:14:24 AM

Title: Different Block use different backgrounds?
Post by: Gararion on December 18, 2006, 02:14:24 AM
Is it possible to have certain block use a different background?

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg.photobucket.com%2Falbums%2Fv726%2FGararion%2Fbg.jpg&hash=92defd891599d7e68401ad69b184de763182b8f1)

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.
Title: Re: Different Block use different backgrounds?
Post by: JPDeni on December 18, 2006, 11:47:31 AM
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.
Title: Re: Different Block use different backgrounds?
Post by: Nokonium on December 18, 2006, 01:29:45 PM
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.
Title: Re: Different Block use different backgrounds?
Post by: Thurnok on December 18, 2006, 11:10:08 PM
Well, you can also get away with something that was discussed awhile back.  Take a look at this post here (http://www.tinyportal.net/index.php?topic=11084.msg91554#msg91554).

Its at least a work-around if you don't want to modify files and such.
Title: Re: Different Block use different backgrounds?
Post by: Nokonium on December 19, 2006, 01:22:25 PM
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)
Title: Re: Different Block use different backgrounds?
Post by: Hack on June 27, 2007, 01:02:14 PM
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)