| 1 |
<?php // $Id: Exp $ |
<?php // $Id: flexiblock.module,v 1.2 2005/07/23 01:03:19 djnz Exp $ |
| 2 |
|
|
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 29 |
* |
* |
| 30 |
* Note that flexiblock is integrated into wgSmarty which makes it even simpler |
* Note that flexiblock is integrated into wgSmarty which makes it even simpler |
| 31 |
* to use: example 3 above becomes |
* to use: example 3 above becomes |
| 32 |
* {flexiblock blocks=2} |
* {foreach from=$blocks.2 item=block} |
|
* {foreach from=$blocks item=block} |
|
| 33 |
* <h3>{$block.subject}</h3> |
* <h3>{$block.subject}</h3> |
| 34 |
* {$block.content} |
* {$block.content} |
| 35 |
* {/foreach} |
* {/foreach} |
| 255 |
|
|
| 256 |
// THEME FUNCTIONS ******************************************************************* |
// THEME FUNCTIONS ******************************************************************* |
| 257 |
|
|
|
|
|
| 258 |
// generate the html for the blocks in a region, returning an array with each element |
// generate the html for the blocks in a region, returning an array with each element |
| 259 |
// containing a block, including the html generated by the block. |
// containing a block, including the html generated by the block. |
| 260 |
// The calling function can then assemble the elements into a table or whatever. |
// The calling function can then assemble the elements into a table or whatever. |
| 261 |
// blocks and their output, sorted by region, are cached to avoid |
// blocks and their output, sorted by region, are cached to avoid |
| 262 |
// expensive |
// expensive |
| 263 |
function theme_flexiblock_blocks($region=0) { |
function theme_flexiblock_blocks($region=FALSE) { |
| 264 |
static $blocks, $regions; |
static $blocks, $regions; |
| 265 |
|
|
| 266 |
// cache all available blocks |
// cache all available blocks |
| 279 |
} |
} |
| 280 |
// TODO sort by weight |
// TODO sort by weight |
| 281 |
} |
} |
| 282 |
// return the blocks for the requested region |
if ( $region===FALSE ) { |
| 283 |
if ( isset($regions[$region]) ) { |
// return the whole array of blocks |
| 284 |
return $regions[$region]; |
return $regions; |
| 285 |
} else { |
} else { |
| 286 |
return array(); |
// return the blocks for the requested region |
| 287 |
|
if ( isset($regions[$region]) ) { |
| 288 |
|
return $regions[$region]; |
| 289 |
|
} else { |
| 290 |
|
return array(); |
| 291 |
|
} |
| 292 |
} |
} |
| 293 |
} |
} |
| 294 |
|
|