"block_page", "help" => "block_help", "admin" => "block_admin"); function block_help() { ?>

Blocks are the boxes visible in the side bars on the left and the right-hand side of the website. They are either exported by the engine or by any of the available modules. To really get your teeth in a drupal website, you are going to have to deal with blocks and administrating blocks in a fairly sophisticated fashion. This means you are going to have to be sensitive to the way the block placement strategy works.

The placement of blocks is delegated to the administrator but for most blocks, i.e. those called "custom blocks", the sole force behind enabling and disabling them is the user itself.

An administrator can lay out and arrange the available blocks to fit in two regions: "left" and "right". Regions simply contain blocks. In addition, an administrator can assign each block (within a region) a weight to sort them vertically. The heavy blocks will sink down whereas the light blocks will be positioned at the top.

As mentioned above, blocks can be arranged to fit in two regions: left and right. For theme builders, each region is identified by a corresponding constant: "left" and "right".

header(); print "\n"; while ($block = db_fetch_object($result)) { if ($state % 3 == 0) print " \n"; print " \n"; if ($state % 3 == 2) print " \n"; $state += 1; } print "
\n"; $blocks = module_execute($block->module, "block"); $theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]); print "
\n"; $theme->footer(); } function block_admin_save($edit) { foreach ($edit as $key=>$value) { db_query("UPDATE blocks SET region = '$value[region]', status = '$value[status]', weight = '$value[weight]' WHERE name = '$key'"); } } function block_admin_display() { global $repository; $result = db_query("SELECT * FROM blocks ORDER BY module"); // Generate output: $output .= "
\n"; $output .= "\n"; $output .= " \n"; while ($block = db_fetch_object($result)) { $module = ($repository[$block->module]["admin"]) ? "module\">$block->module" : $block->module; $status .= "\n"; $weight .= "\n"; $region .= "\n"; $output .= " \n"; unset($status); unset($weight); unset($region); } $output .= "
blockmodulestatusweightregion
". $block->name ."$module$status$weight$region
\n"; $output .= "\n"; $output .= "
\n"; print $output; } function block_admin_overview() { global $site_name; $result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight"); $lblocks .= "\n"; while ($block = db_fetch_object($result)) $lblocks .= " \n"; $lblocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; $result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 1 ORDER BY weight"); $rblocks .= "\n"; while ($block = db_fetch_object($result)) $rblocks .= " \n"; $rblocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; $output .= "

layout 1:

\n"; $output .= "\n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
$site_name header
\n". ($lblocks ? $lblocks : " ") ." \n". ($rblocks ? $rblocks : " ") ."
$site_name footer
\n"; $result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight"); $blocks .= "\n"; while ($block = db_fetch_object($result)) $blocks .= " \n"; $blocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; $output .= "

layout 2:

\n"; $output .= "\n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
$site_name header
 \n". ($blocks ? $blocks : " ") ."
$site_name footer
\n"; $output .= "

layout 3:

\n"; $output .= "\n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
$site_name header
\n". ($blocks ? $blocks : " ") ." 
$site_name footer
\n"; print $output; } function block_admin() { global $op, $edit; print "configure | overview | help
\n"; switch ($op) { case "help": block_help(); break; case "overview": block_admin_overview(); break; case "Save blocks": block_admin_save($edit); // fall through default: block_admin_display(); } } ?>