function plan_url_for_recipe($recipe_tid) { $query = db_select('field_data_field_recipes', 'c'); $query->fields('c', array('entity_id')); $query->condition('c.field_recipes_tid', $recipe_tid); $days = $query->execute()->fetchAll(); $day_tids = array_map(function ($day) { return $day->entity_id; }, $days); $plans = load_day_parent($day_tids)->fetchAll(); $plan_tids = array_map(function ($plan) { return $plan->entity_id; }, $plans); $plan_tids = array_unique($plan_tids); if (count($plan_tids) == 1) { return url_for_tid($plan_tids[0]); } return NULL; }
<?php include 'includes/header.tpl.php'; $content = $variables['page']['content']['system_main']['term_heading']['term']; $main = $content['field_exercises']; if (!$main) { $main = $content['field_recipes']; } if (!$main) { $main = $content['field_motivation']; } $day_data = $main['#object']; $lang = $main['#language']; $plan_day = load_day_parent(array($day_data->tid))->fetchAssoc(); $plan = taxonomy_term_load($plan_day['entity_id']); $sticker_image = $plan->field_sticker_image[$lang][0]; if (!isset($is_monthly_plan)) { $is_monthly_plan = is_monthly_plan($plan, $lang); } if (!$is_monthly_plan) { $intro_header = "Introduction"; $intro_text = $day_data->field_introduction[$lang][0]['value']; } $plan_banner = $plan->field_plan_banner[$lang][0]; $fb_group_id = $plan->field_facebook_group_id[$lang][0]['safe_value']; $show_intro_circle = true; ?> <?php include 'includes/plan-banner.php'; ?>