Custom Block Regions - A Solution


Author Message
GSP

Posted: 3/19/2009
Quote message 

This seems to be quite a requested feature around here so it's posted as a separate topic...

If you subtheme the Artisteer theme you can define new block regions in the template's .info file.

You can then copy the page.tpl.php file from the Artisteer theme folder and add your custom block regions in there.

To continue the example from my subtheming post...

1. Add a line to FooProduction.info for each custom block:

regions[new_block] = new block label

2. Add the following lines (or equivalent) to FooProduction/page.tpl.php for each block:

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>

You can then assign blocks to the custom region in your Artisteer theme. Remember that if you regenerate the parent theme in Artisteer then you'll need to merge the changes you've made in your subtheme with the new page.tpl.php.

Hope this helps someone.
 
Alauddin

Posted: 3/22/2009
Quote message 

thanks GPS

nice idea to the custom changes - I was making it more complicated that it needed to be :)
 
Brian

Posted: 3/23/2009
Quote message 

Quote GSP:


2. Add the following lines (or equivalent) to FooProduction/page.tpl.php for each block:

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>



GSP quick question. I was messing with this and my navigation dissappeared. Is that supposed to be a ; after ($new_block):

Also do I adjust the page.tpl.php and add the new one to both areas (theme and subtheme)?
 
GSP

Posted: 3/23/2009
Quote message 

Brian: The syntax is correct. You can replace {} brackets with the if:/endif; syntax which makes things a bit easier to read in templates.

Example:

if(1==1):
do_stuff();
endif;

is equivalent to:

if(1==1) {
do_stuff();
}

You can also use for:/endfor, foreach:/endforeach; and while:/endwhile; syntax.

Not sure what you did to break the navigation, check to make sure you didn't overwrite anything.

Also, the idea of the subtheme is that you are not directly editing the code that Artisteer outputs - that way if you need to regenerate from Artisteer you don't lose all your custom changes - so you just need to edit page.tpl.php in the subtheme.
 
Koen

Posted: 3/27/2009
Quote message 

Hey,
I've been messing around half a day now but can't seem to figure out where to put the code in the page.tpl.php
Thanks for your help
 
Patrick Visser

Posted: 3/29/2009
Quote message 

Dit the part : Where do I have to place the

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>

Because i place it in the page.tpl.php its not showing in the admin of my theme. Can you please help me on this? or tell me where to place the coding? Also are there no file more to be edit. :-{}
 
Alauddin

Posted: 3/29/2009
Quote message 

Hey Patrick,

Here is what you need to do.

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>

in the above code we are calling this block "new_block"

1) first add this to the .info file in the artister theme folder you created

regions[new_block] = New Footer Block

2) now add the above code to the .tpl files between these lines.

<div class="cleared"></div>

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>

<div class="Footer">

3) go to blocks and you will see the "New Footer Block"

and that should do it.
you now have a the block right above the artisteer generated footer block, but spans accross both sidebars and the content blocks.

This shoud be more than enough customization if you use the block along with Views and Panels.

 
Patrick Visser

Posted: 3/29/2009
Quote message 

:-) Thank you so much Alauddin,

I just did itt haha. Great. Supperrr. Its working now. O yea. I did the Sup Them part to.. So now i don't have to worry about my layout after Exporting to

Greetings. and thanks
 
api

Posted: 9/28/2009
Quote message 

Hi Alauddin,

I have used your last your example

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>

in the above code we are calling this block "new_block"

1) first add this to the .info file in the artister theme folder you created

regions[new_block] = New Footer Block

2) now add the above code to the .tpl files between these lines.

<div class="cleared"></div>

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>

<div class="Footer">

3) go to blocks and you will see the "New Footer Block"
I have done all that you have proposed and i have named $new_block=second
after all steps in "Administer> Site "building when i tried to move on a regoin to my new block everything is ok but when i want to see it like a conent isn't there.
could you help me?

thanks and best regards
 
bhd

Posted: 9/29/2009
Quote message 

Check the input format, also try to run admin>configuration>siteperformance> clear cache
 
Mark C

Posted: 2/23/2010
Quote message 

Thanks for this. Can I ask if anyone can give the step-by-steps to create a region above the two sidebars, like this:
http://budstechshed.com/add-a-wide-sidebar-area-above-your-double-sidebar/

Thanks in advance,
Mark C.
 
bhd

Posted: 2/25/2010
Quote message 

@Mark C

contact me on my email infobluehead@gmail.com
 
Mark C

Posted: 2/25/2010
Quote message 

Done, but check you SPAM, some of my mails have been ending up there.

Mark C.
 
Herfia

Posted: 2/28/2010
Quote message 

Quote Mark C:

Thanks for this. Can I ask if anyone can give the step-by-steps to create a region above the two sidebars, like this:
http://budstechshed.com/add-a-wide-sidebar-area-above-your-double-sidebar/

Thanks in advance,
Mark C.

:-{}I need that tutorial like Mark C question. How to make wide blok like this:
http://budstechshed.com/add-a-wide-sidebar-area-above-your-double-sidebar/

Can you explain for Drupal----please
 
bHd

Posted: 3/2/2010
Quote message 

It was explained in the previous posts. You need some knowledge where to insert the code and some CSS skills to shape it to your needs.

There is no one recipe to do it.
 
Mark C

Posted: 3/2/2010
Quote message 

@Herfia,

BHD very kindly passed me on the code to have a go at it myself. If I get it fixed up I'll post what I did here.

Mark C
www.art-i-steer.com (not affiliated with artisteer.com).
 
smilterman

Posted: 9/17/2010
Quote message 

Hi everybody,

I've been working in drupal for some time now and I'm trying to add block regions with the code suggested above. But I don't see the block region, nor the block name in my dropdown list.
Am I doing something wrong here?
Added the code as suggested on both .info and .tlp.php pages.

Thnx in advance.
 
smilterman

Posted: 9/17/2010
Quote message 

ok, so I just found out why it didn't show up.
There is a page called drupal5_methods with the following code:

'left' => t('left sidebar'),
etc.

here you should ad the new region you created.

That's it,
hope this works in the lay-out

See ya'll


 
smilterman

Posted: 9/17/2010
Quote message 

Problem now is that I can see the region and put a block in it, but it doesn't show when I save the blocks. Very strange, haven't been able to figure it out yet, any suggestions?

Thnx
 
Lawrence

Posted: 9/17/2010
Quote message 

Have you cleared your cache? If not, you're just silly. :-P
 
smilterman

Posted: 9/18/2010
Quote message 

Yep, cleared my cache (several times). Did everything I found on the net. Still driving me crazy...
 
Triumphent

Posted: 9/18/2010
Quote message 

I read all of the above. Sounds nice and dandy athough I didn't test it.
My only comment is this: Why after having purchased Artisteer do we have to fiddle with PHP programming? It was my understanding that Artisteer took care of that part. Obviously, it doesn't!
May as well start from scratch, write the PHP code by hand (and CSS if needed) and save $129!
 
Lawrence

Posted: 9/20/2010
Quote message 

Quote Triumphent:

My only comment is this: Why after having purchased Artisteer do we have to fiddle with PHP programming? It was my understanding that Artisteer took care of that part. Obviously, it doesn't!
May as well start from scratch, write the PHP code by hand (and CSS if needed) and save $129!


Artisteer already provides many many block regions. This is by far more than the average template. Additional block regions should be added by the end user, and if you want more regions, bring it up in the feature requests section. They do read through those sections. :-)

Besides, adding a block region is easy.

In your .info file, add
regions[newregion] = newregion

In your page.tpl.php file, add
<?php print $newregion ?>

To know where your new region should go, simply read through the div tags created by Artisteer. About 10-20 minutes and you should be an expert with divs. :-)
 
Arhon

Posted: 10/5/2010
Quote message 

Quote GSP:

This seems to be quite a requested feature around here so it's posted as a separate topic...

If you subtheme the Artisteer theme you can define new block regions in the template's .info file.

You can then copy the page.tpl.php file from the Artisteer theme folder and add your custom block regions in there.

To continue the example from my subtheming post...

1. Add a line to FooProduction.info for each custom block:

regions[new_block] = new block label

2. Add the following lines (or equivalent) to FooProduction/page.tpl.php for each block:

<?php if ($new_block): ?>
<?php print $new_block; ?>
<?php endif; ?>

You can then assign blocks to the custom region in your Artisteer theme. Remember that if you regenerate the parent theme in Artisteer then you'll need to merge the changes you've made in your subtheme with the new page.tpl.php.

Hope this helps someone.


Hi,

Thanks, I tried your instructions and it worked :-)

How do I create a block that sits snugly underneath my menu, with no margins/space around it? I have tried tinkering with the CSS but still can't manage to get it to disappear completely (see http://www.creationz.co.uk/curryexpress).


Thanks


 
TechZoom.Org

Posted: 2/3/2011
Quote message 

According to latest release of 3.0 Beta
Drupal themes folder has a block.tp.php file too.

So I had too add a new custom region in this block.tpl.php file too.

I have made a tiny effort in putting this altogether in a blog post. You may read it here http://goo.gl/ThaTD

Hope this helps. :)