#62 Block tables

open
nobody
None
5
2002-11-05
2002-11-05
Matthew Leingang
No

Wanted: the ability to arrange blocks in tables (or
rows, which are just n x 1 tables).

$template->set_var('CENTER_BLOCK_TABLE',
$block_table->getBlocks($array,"center"));

It would be easy to adapt or extend the block_i class
to arrange the blocks it gets in a table. I did it
once and maybe I can find that code again. But
something I just thought of is that the class is going
to need to know how many rows or columns the table will
have. Where does that information go? It shouldn't be
hard-coded into the script that generates the page,
although that would be easiest. It could be put in the
template somehow and extracted with Template::set_block
functions, but that's not the intended use of that
function. I'm wondering if this kind of extension
calls for a Block_i database table and corresponding
administration page. There we could give rows and
columns, an additional template to wrap around the
arranged blocks, the key (the block variable currently
called "column") to lookup blocks and the template
variable (e.g., "CENTER_BLOCK_TABLE") to bind it to.
This would make generating blocks for pages as easy as

$block = new Block_i;
$block->addBlocksToTemplate($ary,$template);

Discussion