Preprocess

Lav nye variabler

Her laves 3 nye variabler (date_day, date_month og date_year) som vises via node

  • <?php
  • function navn_preprocess_node(&$vars){
  • $node = $vars['node'];
  • $vars['date_day'] = format_date($node->created, 'custom', 'j');
  • $vars['date_month'] = format_date($node->created, 'custom', 'M');
  • $vars['date_year'] = format_date($node->created, 'custom', 'Y');
  • }

Indsættes i template.php og Drupal har nu 3 nye variabler der kan printes!

I node.tpl kan man nu printe de 3 variabler:

  • <?php print $date_day ?>
  • <?php print $date_month ?>
  • <?php print $date_year ?>

NB!
skal nok styls ..... smides ind i nogle span eller div

$hook

$hook er en generel theme hook

  • function navn_preprocess(&$vars, $hook){
  • ..... et eller andet!...
  • }

eks.

  • function navn_preprocess(&$vars, $hook){
  • $vars['classes'] = $hook;
  • }
Printer en class til alle slags template. = div class="node", div class="blog" etc.