Arrangement-sidene: Visning av arrangørnavn og mer oversiktlig liste over arrangement-info

Når man bruker en standard-mal for utseende, vil arrangøren vises med brukernavn på oppføringene for hvert enkelt arrangement, og info om pulje, type etc. kommer vanligvis etter hverandre uten forklaring. For å få en penere visning, gjør følgende:

  1. Lag en sub-mal (sub-theme, http://drupal.org/node/225125)
  2. Lag en template.php som inneholder dette:
<?php
/**
* Fra http://11heavens.com/putting-some-order-in-your-terms
*/

/**
* Override or insert PHPTemplate variables into the node template.
*/
function phptemplate_preprocess_node(&$vars) {
  // If we have any terms...
  if ($vars['node']->taxonomy) {
    // Let's iterate through each term.
    foreach ($vars['node']->taxonomy as $term) {
      // We will build a new array where there will be as many
      // nested arrays as there are vocabularies
      // The key for each nested array is the vocabulary ID.     
      $vocabulary[$term->vid]['taxonomy_term_'. $term->tid]  = array(
        'title' => $term->name,
        'href' => taxonomy_term_path($term),
        'attributes' => array(
          'rel' => 'tag',
          'title' => strip_tags($term->description),
        ),
      );       
    }

    // http://11heavens.com/putting-some-order-in-your-terms#comment-4681    
    $vars['hvilkenhexcon']= theme('links',$vocabulary[4], array('class'=>'links'));
    $vars['pulje']= theme('links',$vocabulary[1], array('class'=>'links'));
    $vars['type']= theme('links',$vocabulary[2], array('class'=>'links'));
    $vars['kunnskaper']= theme('links',$vocabulary[3], array('class'=>'links'));
    
    // Making sure vocabularies appear in the same order.
    ksort($vocabulary, SORT_NUMERIC);
    // We will get rid of the old $terms variable.
    unset($vars['terms']);
    // And build a new $terms.
    foreach ($vocabulary as $vid => $terms) {
      // Getting the name of the vocabulary.
      $name = taxonomy_vocabulary_load($vid)->name;
      // Using the theme('links', ...) function to theme terms list.
      $terms = theme('links', $terms, array('class' => 'links inline'));
      // Wrapping the terms list.
      $vars['terms'] .= '<div class="vocabulary taxonomy_vid_';
      $vars['terms'] .= $vid;
      $vars['terms'] .= '">';
      $vars['terms'] .= $name;
      $vars['terms'] .= ':&nbsp;';
      $vars['terms'] .= $terms;
      $vars['terms'] .= '</div>';
    }
  }    
}
  1. Lag en kopi av node.tpl.php, kall den node-arrangement.tpl.php (dette blir da en mal som bare brukes for arrangement-sider), og lim inn dette der du vil ha arrangør-info:
  <div class="arrangementinfo">
    <?php if ($taxonomy): ?>
      <div class="terms">
        <?php print $type ?>
        <?php print $kunnskaper ?>
        <?php print $pulje ?>
      </div>
    <?php endif;?>
    <div class="arrangor">
      <span class="float-left">Arrang&oslash;r:&nbsp;</span>
      <?php $viewName = 'arrangornavn'; ?>
      <span class="float-left nopadding"><?php print views_embed_view($viewName, $display_id, $node->nid); //the last argument here is the node id ?> </span>
      &nbsp;
      <?php print $node->field_arrangor[0]['view'] ?>
    </div>
  </div>
  1. Fjern det som står fra før for visning av "terms" (hvis ikke kommer type, pulje etc. dobbelt opp.
  2. Hold musepekeren over ikonet i det øverste venstre hjørnet, klikk på "Flush all caches" for å få forandringene til å vises på nettsidene.
Drupal theme by Kiwi Themes.