You are here

function recipe_ingredient_index_page in Recipe 6

@file recipe_ingredient_index.inc - This is an include file containing most all of the recipe category index page functionality.

1 string reference to 'recipe_ingredient_index_page'
recipe_menu in ./recipe.module
Implementation of hook_menu().

File

./recipe_ingredient_index.inc, line 8
recipe_ingredient_index.inc - This is an include file containing most all of the recipe category index page functionality.

Code

function recipe_ingredient_index_page() {
  drupal_add_css(drupal_get_path('module', 'recipe') . '/recipe_ingredient_index.css', 'module');
  $page_args = array(
    'current_ingredient' => FALSE,
    'ingredient_list' => array(),
    'node_list' => array(),
    'alpha_list' => array(),
  );

  // This is the incoming ingredient id.
  // You are viewing an ingredient, don't get the ingredient list
  if ($iid = intval(arg(2))) {
    $ingredients = recipe_get_ingredients($iid);
    $page_args['current_ingredient'] = array_shift($ingredients);
  }
  else {
    $page_args['ingredient_list'] = recipe_get_ingredients();
    $page_args['alpha_list'] = recipe_get_ingredient_alpha_list($page_args['ingredient_list']);
  }

  // You have an ingredient id, build the node list.
  if ($page_args['current_ingredient']) {
    $page_args['node_list'] = recipe_get_nodes_for_ingredients(array(
      $page_args['current_ingredient']->id,
    ));
  }
  return theme('recipe_ingredient_index_page', $page_args);
}