Theme Gods:
I am aware of all the CSS opportunities available using regions to make my blocks look different. But this doesn't help with the basic structure of a block.
Here's a challenge. I want the title of Block 1 to be at the top of the block, and I want the title of Block 2 to appear at the bottom of Block 2. Is this possible? Or I want one block to have rounded corners, and another to be squared. To do that right now I need to put CSS in the block-tpl.php (I think).
Right now there are certain limitations to block.tpl.php that make it somewhat inflexible across the piece. I expected to be able to create multiple block templates like I can create multiple page templates. This doesn't appear to be the case. It is needed because it is not true for demanding layouts that "a block is a block is a block."
Your wisdom is appreciated.
thanks
Comments
Custom block.tpl.php?
It depends on how may pages you would like to apply the custom block-type to (you can do any number if you have the time and energy).
My Suggestion is for you to add a PHP conditional at the top of your block.tpl.php to test and see the block ID of the current block and then apply a different block template.
I am using a custom template with a similar approach for the main page template:
<?phpif (($block-id == 'xx1') || ($block-id == 'xx2')) {
include 'block-custom.tpl.php'; /*load a custom template for those two block IDs */
return; }
?>
Let me know if you need more detailed support on this.
-----
iDonny - Web CMS Development - Web Design - Web Marketing Advice
-----
Donny Nyamweya - USER25.com
have a look at Nick Lewis's
have a look at Nick Lewis's Curved_Slate theme and the "gizmo" code he describes there
see http://www.nicklewis.org/node/782 for more details
tkgafs
Thanks!
That's what I was hoping someone was going to say. I think I ran across this, but sometimes looking at code when you are not a programmer you just kind of glaze over and fail to realize what you are looking at. You have framed it well and I now get it.
oops
Here's the conditional I inserted at the top of block.tpl.php:
<?phpif (($block-id == 'block-views-Cool Block') || ($block-id == 'block-node-0')) {
include 'block-custom.tpl.php'; /*load a custom template for those two block IDs */
return; }
?>
and I get
Fatal error: Unsupported operand types in /home/sandbox/public_html/themes/pushbutton/block.tpl.php on line 2I altered it to
<?phpif (($block-id == 'block-node-0')) {
include 'block-custom.tpl.php'; /*load a custom template for those two block IDs */
return; }
?>
in case it was the Views-based block that was throwing it off, but still get the same error.
maybe something changed between 4.6 and 4.7? Maybe I'm a hack. Well, we know the latter to be true...
Need to change if statement
The problem comes from $block-id which is not a legal php variable.
In block.tpl.php the block is is broken into two parts $block->module and $block->delta. Using those variable the if would read
if ( ( $block->module == 'views' && $block->delta == 'Cool Block' ) || ( $block->module == 'node' && $block->delta == '0' ) ) {Or if you want to count blocks
use $id.
--
When your problem is solved, please post a follow-up to the thread you started.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
Works like a charm
I'm going to contribute this to the handbook with credit to you folks.
Handbook page submitted for review
http://drupal.org/node/63757
evan