There are 3 ways to display blocks for a flexiblock region in PHPtemplate. In order of complexity (using region 2 as an example):
1) Generate a simple sidebar. Useful if you just want an extra sidebar, or for regions with a single block.
<?php theme('flexiblock_html', 2) ?>
2) Generate themed blocks one by one. Useful for including code between blocks e.g. to lay them out in a horizontal table.
<?php $blocks = theme('flexiblock_blocks', 2); ?>
<?php foreach ( $blocks as $block ) { ?>
<?php echo theme_block((object)$block); ?>
<?php } ?>
3) Total control over layout of individual blocks within a region.
<?php $blocks = theme('flexiblock_blocks', 2); ?>
<?php foreach ( $blocks as $block ) { ?>
<h3><?php echo $block['subject'] ?></h3>
<?php echo $block['content'] ?>
<?php } ?>


Comments
The in-module code and these examples were bad. :(
These work for me. :)
Example 2 & 3 should read:
2)
<?php $blocks = theme('flexiblock_blocks', 2); ?>
<?php foreach ( $blocks as $block ) { ?>
<?php echo theme_block((object)$block); ?>
<?php } ?>
3)
<?php $blocks = theme('flexiblock_blocks', 2); ?>
<?php foreach ( $blocks as $block ) { ?>
<h3><?php echo $block['subject']; ?></h3>
<?php echo $block['content']; ?>
<?php } ?>
.. for correcting this. Documentation amended, patch going into CVS.
I installed flexiblock for a initial test, because it implements an essential feature that Drupal lacks. I've done the simple installation as pointed by the manual. I have the module enabled, created a test block and assigned it to zone 2. Them in my node.tpl.php I put
<?php theme('flexiblock_html', 2) ?>
but nothing get expanded. Changing region number didn't help. Also setting the block to left/right made no difference.
Am I missing something? Any clue of what's wrong?
... so I am not sure what the problem is. You could try the following correction which is on its way into the code anyway ...
In flexiblock.module, after the comment '// get all the blocks' in line 269, replace
$blocks = block_list('all');
with
$blocks = module_invoke('block', 'list', 'all');
... but I don't think that will make any difference. Does it work if you put the zone/region in page.tpl.php?
...what I don't get is, are we supposed to 'replace' the code with your snippets in the .tpl files, or just add them. Does it matter whether or not the template is already activated or do we need to do the changes to the blocks first, then enable the themes. Sorry about the hassle, but I have been trying to get this to work in Friends Electric with 0 luck. I want this to work, but it's just not. What am I doing wrong? Thanks
Hi djnz.
Does it work if you put the zone/region in page.tpl.php?
Nope. Nothing expanded. I also made the correction you suggested, and as expected it didn't make any difference. I'm (still) using 4.6.0.
Thanks for your support.
I cannot get this to work. I have tried multiple themes and engines. djnz, I very much appreciate your work. May I ask what theme you used, what engine, what file you modified, where, and what you modified and with what? I assume on this site it's wgbluemarine running with wgsmarty and you modified the page.tpl file located in the templates folder. That is my guess, but I am not certain. Obviously I'm missing something simple, however, an exact example will let me and ohers know where our problem is. Thanks for your help.
I think the best thing to do is set up a demo site with the Friends Electric theme, and wgBluemarine, so you can see it in action. I will make sure the instructions work by setting up from a new download of Drupal: I will work on this over the coming hours so watch this space.
djnz, I greatly appreciate your efforts. I know that's extra work for you, particularly when I'm probably missing something simple. I will watch this space VERY closely. Thanks again.
FYI, I'm using a slightly modified "greenthing" theme, which uses PHPTemplate. I also tried the following code just to try the other approach:
<?php
$blocks = theme('flexiblock_blocks', 2);
print_r($blocks);
?>
Nothing gets displayed. $blocks comes as an empty array.
Looking at the source I didn't see anything strange, but the following on line 196 rung a bell:
$mapping["{$module}_$delta"] = $block['flexi'];
Do you really mean "{$module}"? The "${module}" syntax (notice the difference) is often used to delimit variables with surrounding text (which seems the case), and produces completely different results than "{$module}".
(Unfortunately, though, I applied this "fix" to the module, and it still didn't work.)
Thanks again, djnz. BTW, I'm the same anonymous that posted replies #3 and #6. :-)