You are here

function theme_recipe_name_index_page in Recipe 6

1 theme call to theme_recipe_name_index_page()
recipe_name_index_page in ./recipe_name_index.inc
@file recipe_name_index.inc - This is an include file containing most all of the recipe name index page functionality.

File

./recipe_name_index.inc, line 17
recipe_name_index.inc - This is an include file containing most all of the recipe name index page functionality.

Code

function theme_recipe_name_index_page($alpha_list = NULL, $node_list = NULL) {

  // Render the alpha pager.
  $output = '<div class="recipe_name_alpha_list">';
  $list = array();
  foreach (range('a', 'z') as $letter) {
    if (isset($alpha_list[$letter])) {
      $list[] = l(strtoupper($letter), 'recipe/byname', array(
        'fragment' => 'alpha_' . $letter,
      ));
    }
    else {
      $list[] = $letter;
    }
  }
  if (isset($alpha_list['0-9'])) {
    $list[] = l('[0-9]', 'recipe/byname', array(
      'fragment' => 'alpha_0-9',
    ));
  }
  else {
    $list[] = '[0-9]';
  }
  $output .= implode(" - ", $list);
  $output .= '</div>';
  $output .= '<div class="recipe_name_list">';

  // Render the node_list next.
  if ($node_list != NULL) {
    if (count($node_list) > 0) {
      $output1 = '';
      $last_alpha = '-';
      foreach ($node_list as $node) {
        if ($node->letter != $last_alpha) {
          if ($last_alpha != '-') {
            $output1 .= "</p></fieldset>";
          }
          $output1 .= '<fieldset><legend><a name="alpha_' . $node->letter . '">' . strtoupper($node->letter) . '</a></legend><p>';
          $last_alpha = $node->letter;
        }
        $output1 .= l($node->title, 'node/' . $node->nid) . '<br/>';
      }
      $output1 .= "</p></fieldset>";
      $output .= $output1;
    }
    else {
      $output .= theme('box', t('No matching recipes'));
    }
  }
  $output .= "</div>";
  drupal_set_title(t('Find by recipe name'));
  return $output;
}