Still somewhat new to this....

I have run into a problem and I am not sure how to go about getting this to work.

http://www.kdmp.ca/testground/blocks.jpg

In the linked image there are two different styles of menu blocks. There will be changes to those menu blocks so I can't just 'hard code' it into the theme. Is there a way to allow for two different styles of menu blocks to be used?

Comments

vm’s picture

custom block.tpl.php files

you can target a block by using it's delta

more information in the theme developers handbook.

feeper’s picture

Hi verymisunderstood,

I have read it over. I guess I am not sure how that new block is called. Somewhat new to Drupal theming.

Would anybody mind helping a somewhat newbie to the Drupal theming...help me make sense of this? :)

vm’s picture

Each block has a delta or #
hover over the block name in administer -> blocks
there you will see the block #

example: the login block provided by core is always user/0

that information along with http://drupal.org/node/104319

should be enough. If you have specific questions you can be given specific answers.

feeper’s picture

Well this is probably more of a css question...but how would I get the blocks to show up the way I have them in the layout image with a custom block.tpl?

I can see that the custom blocks.tpl will stack in a vertical row. I didn't see anything in the reading material about this and it may just be css controlled in the custom block. My two dimensional thinking.

feeper’s picture

okay further more to the above.

I have created two new regions. Menu1 and Menu2. They are displaying correctly. Which is good.

Here is the code that I have in block.tpl.php:

<?php
    $block_module = $block->module;
    // force delta to be alphanumeric
    $block_name = $block_module . '-' . preg_replace('/[^\w]/', '', $block->delta);
    switch ($block_name) {
        case 'menu1':                // Primary links
        case 'menu2':        // a custom Views block named "Cool Block"
            if ( @include("block-$block_name.tpl.php") ) {
                return;
            }
            break;
    }
?>

Block-menu1.tpl.php:

<div class="block block-<?php print $block_module; ?>" id="block-<?php print $block_name; ?>">
<h1 class="title"><?php print $block->subject; ?></h2>
<div class="content"><?php print $block->content; ?></div>

Block-menu2.tpl.php:

<div class="block block-<?php print $block_module; ?>" id="block-<?php print $block_name; ?>">
<h2 class="title"><?php print $block->subject; ?></h2>
<div class="content"><?php print $block->content; ?></div>

Right now I am aiming for the custom blocks to be seen...but I am not sure what I am doing wrong here and the documentation has helped thus far...but just not sure what else I am missing here.

Thanks!

feeper’s picture

Now this is confusing.

I thought block.tpl.php is used to show contents in a region???

Why is that I can remove block.tpl.php from my theme directory and it still shows me block content??

feeper’s picture

Well it might help if I had named the block file correctly. I corrected the name of the custom block file to coincide with the name of the region...voila it worked.

Now I have a problem of the blocks stacking one over each other.

http://www.kdmp.ca/testground/blocks2.jpg

Current custom block code:

<div class="first_menu_title_bar"><div class="first_menu_text"><?php print $block->subject; ?></div>
<div class="first_menu_box"><?php print $block->content; ?></div>

If I remove the references to the blocks in the page.tpl.php and replace it with just the div's that I have in my custom block file it appears fine. Any suggestions what may be causing this in drupal ... or is it my css??

Code from page.tpl.php:

<div id="first_menu_container">
     	<div id="first_menu_inner">
            <div id="left_inner_first_menu_container">
            	<div class="left_menu_box">
                	<?php if ($menu_top1) { ?>
                    <?php print $menu_top1 ?>
                    <?php } ?>
                </div>
                <div class="right_menu_box">
                	<?php if ($menu_top2) { ?>
                    <?php print $menu_top2 ?>
                    <?php } ?>
                </div>
            </div><!-- Close of left_inner_first_menu_container -->
            <div id="right_inner_first_menu_container">
            	<div class="left_menu_box">
                	<?php if ($menu_top3) { ?>
                    <?php print $menu_top3 ?>
                    <?php } ?>
                </div>
                <div class="right_menu_box">
                	<?php if ($menu_top4) { ?>
                    <?php print $menu_top4 ?>
                    <?php } ?>
                </div>
            </div>
        </div><!--Close of first_menu_inner-->
     </div><!-- Close of first_menu_container-->

CSS for the above:

#left_inner_first_menu_container {
	float: left;
	width: 386px;
}

#right_inner_first_menu_container {
	float: right;
	width: 386px;
}

.left_menu_box {
	float: left;
	text-align: left;
	height: 100px;
	width: 180px;
	padding-top: 15px;
	padding-left: 6px;
	padding-right: 6px;
}

.first_menu_title_bar {
	background-image: url(images/menu_sm_title_bkd.jpg);
	width: 177px;
	height: 27px;
}

.first_menu_text {
	padding-top: 2px;
	padding-bottom: 2px;
	padding-left: 5px;
	font-size: 14px;
	color: #FFFFFF;
	font-weight: bold;
}

.first_menu_box {
	width: 175px;
	height: 125px;
	border-style: solid;
	border-width: 1px;
	border-color: #CCCCCC;
	background-color: #FFFFFF;
}

Anybody have any ideas what I am doing wrong??

feeper’s picture

Anybody?

feeper’s picture

I have otherwise stumped people...or I haven't provided enough details.... Could somebody let me know which one?? :P

vm’s picture

have a link to the site with the blocks enabled so that we can take a look at the source code?