Hi,

Am using 4.6 and then the 1.8 version of the flexiblock module:

$Id: flexiblock.module,v 1.8 2005/08/06 21:35:35 djnz Exp $

I'm using the phptemplate version of bluemarine, and I want to put a block (for banner ads and google ads) just beneath the primary links -- not in the header part but at the top of the center column of the page(s).

I've read all the documentation, but I'm still confused, so perhaps you could enlighten me.

In which file of bluemarine do I have to put the code(s)? -- http://www.webg8.com/h/node/55 . And where exactly in the file(s)? I've read somewhere that you have to put the code in page.tpl.php. I've tried pasting the page.tpl.php code here for your convenience but I can't post it because it was deemed suspicious code by this site's filter.

At any rate, here's the first part of the flexinode/debug page. I've read the references to it, but don't exactly understand how it figures in the scheme of things.

Default mapping
Array
(
[themes] =>
)

Current mapping
Array
(
[themes] =>
[theme] =>
)

Flexiblock block list
Array
(
)

Where exactly are the 9 regions in a given page? -- There are 9 right? How were these regions established? Are they set in the Drupal core, or have they been set only in flexiblock?

Thanks in advance! :)

Comments

kbahey’s picture

I wrote an article on my web site on how to use flexinode for adsense. Using it for the banner module is almost the same.

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

noid’s picture

Thanks Khalid. Already saw your article actually, and planning to use it once I'm able to figure out where to put the flexiblock code. :) So my problem is where do you exactly put the code in the bluemarine theme (which file and where in that file) when you say


Then, in your theme, assuming it is phptemplate based, you place the following code: 

<?php $blocks = theme('flexiblock_blocks', 1)
; ?>

<?php foreach ( $blocks as $block ): ?>

 <?php print '<div align="center">' . $block
['content'] . '</div>'; ?>

<?php endforeach; ?>

And how do you determine which region is which, e.g., where is region 3, and how come that area of the page is designated to be region 3? Are the regions user-defined? If yes, how exactly? Sorry, I haven't mastered HTML and php yet.

kbahey’s picture

My wording was not that clear. I will try to change it a bit. I mean you put it in page.tpl.php whereever you want it to be.

As for regions: YOU determine where they go. So you set the convention for yourself: say region 9 is at the end of each node, and region 1 is at the top of each node, ....etc. This is the second argument to the theme() call, as in: ('flexiblock_blocks', 1) is region 1.

Note that my technique assumes that there will only be one block in the region you use in the theme. This is easier than relying on the block id.

Ask more if this is not clear.

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

alexandreracine’s picture

You decide where to put it in the page.tpl.php of your theme.

Let's say that you want bloc 1 and bloc 2 to be around the left colum.

      <?php $blocks = theme('flexiblock_blocks', 1); ?>
      <?php foreach ( $blocks as $block ) { ?>
        <h3><?php echo $block['subject'] ?></h3>
        <?php echo $block['content'] ?>
      <?php } ?>
      <?php if ($sidebar_left) { ?>
        <?php print $sidebar_left ?>
      <?php } ?>
      <?php $blocks = theme('flexiblock_blocks', 2); ?>
      <?php foreach ( $blocks as $block ) { ?>
        <h3><?php echo $block['subject'] ?></h3>
        <?php echo $block['content'] ?>
      <?php } ?>

Sidebar left is the normal left bloc area. Now if you put something in the bloc 2 or 1 with flexibloc, they will show higher or lower then your left sidebar. Let's say you want to put a little banner before your left colum, this could help.

noid’s picture

Hi guys,

Thanks for your replies. Was actually able to figure it out before I saw your posts, but thanks for replying -- it confirmed my solution. To add to your posts, I put the code (tried Khalid's and djnz's (the developer) code and each worked) right before and after the content. e.g.,

Top (adsense) banner

<td valign="top">

<?php $blocks = theme('flexiblock_blocks', 3); ?>

<?php foreach ( $blocks as $block ): ?>

 <?php print '<div align="center">' . $block['content'] . '</div>'; ?>

<?php endforeach; ?>


      <?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>

Bottom (adsense) banner

 <?php print $content; ?>

<?php $blocks = theme('flexiblock_blocks', 3); ?>

<?php foreach ( $blocks as $block ): ?>

 <?php print '<div align="center">' . $block['content'] . '</div>'; ?>

<?php endforeach; ?>

Now I have a question. Sometimes -- am using the bottom banner right now -- the block doesn't show the google ad and there's just an empty space there. Is this a flexiblock issue (the hack not totally working with the theme and/or the adsense module) or a google issue (not enough ads from google for example)?

However, I suspect it's the former -- for the left side ad, I use a core block and not flexiblock, and it always displays an ad. I'm also thinking that it's not the adsense module's fault (at least, alone) since there should be times that it should not work in my left side block, but that's not happening -- it's always working.

kbahey’s picture

Now I have a question. Sometimes -- am using the bottom banner right now -- the block doesn't show the google ad and there's just an empty space there. Is this a flexiblock issue (the hack not totally working with the theme and/or the adsense module) or a google issue (not enough ads from google for example)?

I think this should be a Google issue. They cannot figure out what your page is about to display ads on it, or cannot find much keywords, or they already displayed enough for the keywords, ...etc.

If you want to be sure, check one time when it does display an ad, vs another when it does not, and check the source. Do you see javascript and the <--adsense--> comments in the HTML? If so, then it is definitely Google.
--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

noid’s picture

You're right, Khalid. Again, was able to figure it out before I saw your post, and your latest reply confirmed it.

Here's why (might also be helpful to those who are optimizing their sites for adsense):

http://www.problogger.net/archives/2005/03/04/positioning-your-adsense-a...

In the article, it says that Google executes the adsense scripts in sequence depending where the script is in the template. The left side always had ads because it was the first script being executed. And when Google runs out out of ads to serve, it doesn't display anything of course in the center column or where the nodes are. Since I wanted personally to have an ad in the middle always (the article and other sources say this is more effective), I moved the left block to the right. :)

Was also able to display the ads after each post by putting the flexiblock code after the print $content part of node.tpl.php (as you added and suggested in your article). This displayed the ad right after the post -- on the other hand, putting it after the print $content part of page.tpl.php placed the ad after the comments). Here's the exact code in node.tpl.php :

<div class="content"><?php print $content?></div>
	    
<?php $blocks = theme('flexiblock_blocks', 3); ?>

<?php foreach ( $blocks as $block ): ?>

 <?php print '<div align="center">' . $block['content'] . '</div>'; ?>

<?php endforeach; ?>
    
<div class="links">&raquo; <?php print $links?></div>
  </div>

One quirk I found about this placement is that the ad also shows up in the teaser which is a good thing -- although when I found this out I was afraid that a list of teasers might violate the Google adsense rule that there should only be three ads on a page, but I was relieved to discover that Google automatically cuts off serving ads after the third ad is served.

Thanks a lot guys for your help! Hope this thread helps others and makes things easier. :)