All pastes #208923 Raw Edit

Someone

public php v1 · immutable
#208923 ·published 2006-10-18 21:59 UTC
rendered paste body
/**Fine-grained node placing in themes. This is a technique that allows you to deal with each node separatelly (e.g. place a node right, another left, two in middle.. etc).This solution tries to store all the nodes in an array, and give that to the themer so they can decide how to ouptut these nodes.For example, if you want to display them in two columns, you will need to iterate over the array, print the odd in left column, and even on right column.To make this work, first you need this code in your template.php:*/function yourtheme_node($node, $teaser=0, $page=0) {  set_themed_node(phptemplate_node($node, $teaser, $page));}   function set_themed_node($node=NULL) {  static $themed_nodes;  if ($node) {    $themed_nodes[] = $node;  }  else {    return $themed_nodes;  }}function _phptemplate_variables($hook, $vars) {  $myvars = array();  switch ($hook) {    case 'page':      $myvars['nodes'] = set_themed_node();      break;  }   return $myvars;}/**Now in your page.tpl.php, you have a new array called $themed_nodes, each node is an item in the array.So you can do something like (just rough example):*/<?php          foreach ($themed_nodes as $key => $mynode) {            if ($key%2) {              $odd_nodes .= $mynode;            }                else {              $even_nodes .= $mynode;            }          }        ?>        <table width="100%">          <tr>            <td class="left">              <?php print $odd_nodes; ?>            </td>            <td class="right">              <?php print $even_nodes; ?>            </td>           </tr>        </table>        <?php print $content; // this is needed to print extra stuff (pagination, ..etc) ?>/*Hope it was any useful to you.- alienbrain*/