function bseurope_form_alter(&$form, &$form_state, $form_id) { //if it is the exposed filter view if ($form_id == 'views_exposed_form' && ($form_state['view']->name == 'experiencias' || $form_state['view']->name == 'highlights')) { //get the childern of the term if ($child_terms = taxonomy_get_children(38)) { //only care about the tids $child_terms_tids = $child_terms_infos = array(); foreach ($child_terms as $child) { $child_terms_tids[] = $child->tid; } foreach ($form["#info"] as $info) { //var_dump($info); $child_terms_infos[] = $info["value"]; } //for the exposed filter, alter the available options if (isset($form['field_lugar_tid_i18n']['#options'])) { foreach ($form['field_lugar_tid_i18n']['#options'] as $tid => $term) { //is is a child term? if (in_array($tid, $child_terms_tids)) { //leave it } else { //remove it unset($form['field_lugar_tid_i18n']['#options'][$tid]); } } } //for the exposed filter, alter the available options if (isset($form['field_lugar1_tid_i18n']['#options'])) { foreach ($form['field_lugar1_tid_i18n']['#options'] as $tid => $term) { //is is a child term? if (in_array($tid, $child_terms_tids)) { //leave it } else { //remove it unset($form['field_lugar1_tid_i18n']['#options'][$tid]); } } } } } }
set_time_limit(10000); ini_set('memory_limit', '256M'); // Perform import as admin user global $user; $user = user_load(array('uid' => 1)); /** * MAIN */ // Find the correct term-id from the vocabulary name $taxonomy_vid = taxonomy_vocabulary_machine_name_load('user_type'); // Get the taxonomy tree for the user term vocabulary $taxonomy_tree = taxonomy_get_tree($taxonomy_vid->vid); // Step through each tree element, and find leaf-children plus their parents foreach ($taxonomy_tree as $id => $item) { $tid = $item->tid; $children = taxonomy_get_children($tid, $taxonomy->vid); if (empty($children)) { // This must be a leaf since it has no children $parents = taxonomy_get_parents_all($tid); $txt = '"'; $first = TRUE; while (!empty($parents)) { $litem = array_pop($parents); $txt .= ($first ? '' : '-->') . $litem->name; $first = FALSE; } $txt .= '", "' . $item->tid . '"' . "\n"; $output .= $txt; } } $iso_output = utf8_decode($output);
/** * Get the children of the current category item by id. */ protected function getChildren(\EntityMetadataWrapper $wrapper) { $vocabulary = taxonomy_vocabulary_machine_name_load($this->getBundle()); $children = taxonomy_get_children($wrapper->getIdentifier(), $vocabulary->vid); // Exit if there is not children. if (empty($children)) { return; } $return = array(); // Get just an array of id. foreach ($children as $term) { $return[] = $term->tid; } return $return; }
$i++; } ?> </nav> </div> </header> <main class="cob-portalMain" role="main"> <div class="cob-portalMain-container"> <div class="cob-portalSidebar" id="taxonomy-term-<?php echo $term->tid; ?> "> <nav class="cob-portalSidebar-nav"> <?php if (isset($term->parent)) { $siblings = taxonomy_get_children($term->parent->tid); } else { $categories = taxonomy_vocabulary_machine_name_load('categories'); $siblings = taxonomy_get_tree($categories->vid, 0, 1); } foreach ($siblings as $t) { $options = ['html' => true]; if ($term->tid === $t->tid) { $options['attributes'] = ['class' => ['current']]; } echo l("<span class=\"title\">{$t->name}</span><span class=\"description\">{$t->description}</span>", 'taxonomy/term/' . $t->tid, $options); } ?> </nav> </div> <?php
?> <?php foreach ($children as $child) { ?> <?php if (isset($child->field_taxonomy_class['und'][0]['safe_value']) && $child->field_taxonomy_class['und'][0]['safe_value'] == 'subtitulo') { ?> <ul class="col-md-3"> <li> <h4><?php print $child->name; ?> </h4> </li> <?php $has_children = taxonomy_get_children($child->tid); ?> <?php if (!empty($has_children)) { ?> <?php foreach ($has_children as $item) { ?> <li> <?php print l($item->name, './taxonomy/term/' . $item->tid); ?> </li> <?php } ?>
/** * Implements template_preprocess_page * * Available vars: * * */ function medtravel_preprocess_page(&$variables) { // loads entity data $url_params = current_path(); $params = explode('/', $url_params); // if belongs to micro entity type if ($params[0] == 'micro') { $id = $params[1]; $entity = entity_load('micro', array($id)); if (!empty($entity)) { $variables['entity_not_found'] = false; $entity = $entity[$id]; // get the current language $lang = entity_language('micro', $entity); $variables['micro'] = $entity; // builds variables $header_img = file_load($entity->field_header_img['und'][0]['fid']); $body_img = file_load($entity->field_body_img['und'][0]['fid']); // field with multiple values $variables['map'] = $entity->field_map['und']; $variables['gallery'] = $entity->field_footer_gallery['und']; $variables['footerLinks'] = $entity->field_footer_link[$lang]; $variables['footerAttachments'] = $entity->field_footer_attachment[$lang]; $variables['listItems'] = $entity->field_list_items[$lang]; $variables['mid'] = $entity->mid; $variables['name'] = $entity->name; $variables['category'] = $entity->category; $variables['likes'] = $entity->likes; $variables['num_likes'] = $entity->num_likes; $variables['social_fb'] = $entity->social_fb; $variables['social_tw'] = $entity->social_tw; $variables['share'] = $entity->share; $variables['bookmarks'] = $entity->bookmarks; $variables['title_links'] = $entity->title_links; $variables['title_attachments'] = $entity->title_attachments; $variables['map_title'] = $entity->map_title; $variables['related'] = module_invoke('related', 'block_view', 'related'); } else { $variables['entity_not_found'] = true; } } if (drupal_is_front_page()) { //get language global $language; $langcode = $language->language; if ($langcode == 'es') { $langcode = ''; } if ($langcode == 'en') { $langcode = '_en'; } $variables['langcode'] = $langcode; //get data $data = get_home_data(); $data = $data[0]; //render home blocks $variables['home_block'] = module_invoke('home', 'block_view', 'home_block'); $video = file_load($data['video']); if (!empty($video)) { $variables['home_video'] = file_create_url($video->uri); } $video_img = file_load($data['video_img']); if (!empty($video_img)) { $variables['home_video_img'] = file_create_url($video_img->uri); } $variables['home_title'] = $data['title' . $langcode]; $variables['home_description'] = $data['description' . $langcode]; $variables['home_que_visitar'] = $data['tab_que_visitar']; $variables['home_donde_quedarme'] = $data['tab_donde_quedarme']; $variables['home_como_moverme'] = $data['tab_como_moverme']; // home tabs $criteria = array('lugares', 'transporte', 'hospedaje'); foreach ($criteria as $crit) { $options = array(); // if is transporte take data from micro table if ($crit == 'transporte') { $children = query_tab_special_class($criteria); foreach ($children as $child) { $options[$child->mid] = $child->name; } } else { $children = query_tab($crit); foreach ($children as $child) { $options[$child->tid] = $child->name; } } $variables[$crit] = $options; } } // if is a taxonomy term if (isset($variables['page']['content']['system_main']['term_heading'])) { global $language; $langcode = $language->language; $tid = arg(2); $items = array(); $children = taxonomy_get_children($tid); // if there is children change $cat_children if (!empty($children)) { $cat_children = $children; $variables['children'] = $children; } else { $parent_src = taxonomy_get_parents($tid); $parent = reset($parent_src)->tid; $cat_children = taxonomy_get_children($parent); } foreach ($cat_children as $cat_child) { $micros = query_micro_all($cat_child->tid); $cont = 0; foreach ($micros as $micro) { $cont++; } $micros_num = count($micros); $items[] = array('tid' => $cat_child->tid, 'name' => $cat_child->name, 'number_items' => $cont); } // load term $term = taxonomy_term_load($tid); // Text $description = field_get_items('taxonomy_term', $term, 'field_taxonomy_description'); $description = field_view_value('taxonomy_term', $term, 'field_taxonomy_description', $description[0]); $term_img_src = file_load($term->field_taxonomy_image['und'][0]['fid']); $term_img = file_create_url($term_img_src->uri); $variables['term_img_header'] = $term_img; $variables['term_title'] = $term->name; $variables['term_description'] = $description; $variables['items_menu'] = $items; $variables['micros'] = fieldQueryMicro($tid); $variables['langcode'] = $langcode; } }
if ($token == true) { $memberships = array_merge($special_memberships, $memberships); $checked_plan = reset($special_memberships)->membership_type_id; } ?> <ul class="pure-g"> <?php $num_of_plans = count($memberships); ?> <?php foreach ($memberships as $membership) { $plan_price_terms = taxonomy_get_term_by_name($membership->name, 'fitness_plan_price'); $plan_price = reset($plan_price_terms); $plan_feature_parent = reset(taxonomy_get_term_by_name($membership->name, 'fitness_plan_features')); $plan_features = taxonomy_get_children($plan_feature_parent->tid, $plan_feature_parent->vid); $price = $plan_price->field_planprice['und'][0]['value']; if ($price <= 1) { $price = "Free"; } ?> <li class="pure-u-1 pure-u-md-1-<?php echo $num_of_plans > 3 ? '2 pure-u-lg-1-4' : '3'; ?> "> <label for="<?php print $plan['d_plan']->m_plan_id; ?> " class="form-item"> <input id="<?php print $membership->name;
* - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */ $all_service_statistics = array(); if ($term = taxonomy_term_load($output)) { // If ministry term. $nodes = array(); $child_terms = taxonomy_get_children($term->tid); if (!empty($child_terms)) { foreach ($child_terms as $tid => $term_object) { $term_nodes = taxonomy_select_nodes($term_object->tid, FALSE); $nodes = array_merge($nodes, $term_nodes); } } else { $nodes = taxonomy_select_nodes($term->tid, FALSE); } if (!empty($nodes)) { foreach ($nodes as $nid) { $service_statistics = _teenus_get_statistics($nid, $view->old_view[0]->exposed_data['field_fcf_mootmise_aasta_tid']); if (!is_null(@$total_statistics['rahuolu'])) { @($all_service_statistics['rahuolu'] += $service_statistics['total']['rahuolu']); } elseif (isset($all_service_statistics['rahuolu']) && !is_null($all_service_statistics['rahuolu'])) { @($all_service_statistics['rahuolu'] = $total_statistics['rahuolu']);
function footmali_get_tag_articles($tid) { $child_categories = taxonomy_get_children($tid); $operator = '='; // If child category make an array of all the tids and set operator if (count($child_categories) > 0) { $categories = array($tid); $operator = 'IN'; foreach ($child_categories as $category) { array_push($categories, $category->tid); } $tid = $categories; } $articles_query = new EntityFieldQuery(); $articles_query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'article')->fieldCondition('field_tags', 'tid', $tid, $operator)->propertyCondition('status', NODE_PUBLISHED)->range(0, 20)->pager(5)->propertyOrderBy('created', 'DESC'); $articles_result = $articles_query->execute(); $articles_ids = count($articles_result) ? array_keys($articles_result['node']) : false; return $articles_ids ? node_load_multiple($articles_ids) : false; }
function user_get_proxy_list() { $proxy_taxo_data = taxonomy_get_term_by_name('Carrefour Proxy'); $proxy_ids = NULL; foreach ($proxy_taxo_data as $data) { $proxy_ids = $data->tid; } $proxy_child_ids = taxonomy_get_children($proxy_ids); $array_proxy = array(); if (!empty($proxy_child_ids)) { foreach ($proxy_child_ids as $value) { $array_proxy[] = $value->tid; } } return $array_proxy; }
<?php } ?> </ul> <ul data-color="#ec008c" > <h4><a href="<?php $cat = taxonomy_term_load(5); $cat_url = drupal_get_path_alias('taxonomy/term/' . $cat->tid); echo $base_url . '/' . $cat_url; ?> "><?php echo $cat->name; ?> </a></h4> <?php $tax_childs = taxonomy_get_children(5, $vid = 0); foreach ($tax_childs as $tax_link) { $tax_url = drupal_get_path_alias('taxonomy/term/' . $tax_link->tid); ?> <li><a href="<?php echo $base_url . '/' . $tax_url; ?> "><?php echo $tax_link->name; ?> </a></li> <?php } ?> </ul> <ul data-color="#000" >
/** * Override or insert variables into the node template. */ function uber_bootstrap_preprocess_taxonomy_term(&$vars) { //Добавляем контекстные ссылки для taxonomy_term display if ($vars['view_mode'] == 'teaser' || $vars['view_mode'] == 'teaser_mini') { $vars['teaser'] = TRUE; $vars['classes_array'][] = 'contextual-links-region'; $vars['classes_array'][] = 'taxonomy-term-' . $vars['view_mode']; $vars['title_suffix'] = array('contextual_links' => array('#type' => 'contextual_links', '#contextual_links' => array('taxonomy_term' => array('taxonomy/term', array($vars['tid']))))); } //Бонусы для продуктов if ($vars['view_mode'] == 'teaser' && $vars['vocabulary_machine_name'] == 'bonus') { $vars['content']['title'] = array('#markup' => '<div class="title">' . $vars['name'] . '</div>', '#weight' => -10); $vars['content']['field_image']['#weight'] = -20; } //Команда if ($vars['view_mode'] == 'teaser_mini' && $vars['vocabulary_machine_name'] == 'team') { $vars['content']['title'] = array('#markup' => '<div class="title">' . $vars['name'] . '</div>', '#weight' => -10); $vars['content']['field_image']['#weight'] = -20; $class = array('ctools-use-modal', 'ctools-modal-uber', 'btn', 'btn-default', 'btn-lg'); $menager_link = l('Связаться с менеджером', '/ajax/nojs/41559/' . $vars['tid'], array('attributes' => array('class' => $class))); $vars['content']['menager_link'] = array('#markup' => '<div class="btn-menager-link">' . $menager_link . '</div>', '#weight' => 100); } //МАрки авто и категории if ($vars['view_mode'] == 'teaser' && array_search($vars['vocabulary_machine_name'], array('marks', 'catalog')) !== FALSE) { $title = l(check_plain($vars['name']), 'taxonomy/term/' . $vars['tid']); $btn = l('Перейти', 'taxonomy/term/' . $vars['tid']); $vars['content']['title'] = array('#markup' => '<div class="title">' . $title . '</div>', '#weight' => -10); $vars['content']['field_image']['#weight'] = -20; $node_count = frz_tweaks_helper::term_nc($vars['tid'], FALSE); $txt = format_plural($node_count, '@count product', '@count products'); //$txt = t('!nc products', array('!nc' => $node_count)); if (isset($vars['field_cargo'][LANGUAGE_NONE][0]['value']) && $vars['field_cargo'][LANGUAGE_NONE][0]['value'] == 1) { $tooltip = t('There are spare parts for trucks'); $field_cargo_icon = '<div class="cargo-icon" data-toggle="tooltip" data-placement="top" title="' . $tooltip . '" ></div>'; } else { $field_cargo_icon = ''; } $vars['content']['node_count'] = array('#markup' => '<div class="node-count">' . $txt . $field_cargo_icon . '</div>', '#weight' => 1); $vars['content']['btn-link'] = array('#markup' => '<div class="btn-link">' . $btn . '</div>', '#weight' => 50); } //Категории авто if ($vars['view_mode'] == 'teaser' && array_search($vars['vocabulary_machine_name'], array('catalog')) !== FALSE) { $childrens = taxonomy_get_children($vars['tid']); $list_children = array(); foreach ($childrens as $children) { $list_children[] = l($children->name, 'taxonomy/term/' . $children->tid); } $count_childrens = count($list_children); $title = format_plural($count_childrens, '@count category', '@count categories'); $options = array('title' => $title, 'items' => $list_children); $vars['content']['subcategories'] = array('#markup' => '<div class="subcategories-list">' . theme('bootstrap_dropdown_button', $options) . '</div>', '#weight' => -10); // dpm($vars); } }
} // Lookup RecTrac types and add them to the current term listing. if (!empty($data['term']->field_rectrac_category)) { $types = cob_rectrac_types($data['term']->field_rectrac_category['und'][0]['value']); foreach ($types as $t) { $external_term_links[$tid][] = ['url' => 'https://bloomington.in.gov/webtrac/cgi-bin/wspd_cgi.sh/wbsearch.html?xxtype=' . $t->Type, 'title' => $t->Descript, 'summary' => '']; } } // Merge in any content from $external_term_links if (!empty($external_term_links[$tid])) { foreach ($external_term_links[$tid] as $link) { $items[] = ['title' => $link['title'], 'summary' => "\n <article class=\"cob-mainText\">\n <h1><a href=\"{$link['url']}\" target=\"_blank\">{$link['title']} <span class=\"cob-indicator-externalLink\">(external link)</span></a></h1>\n <p>{$link['summary']}</p>\n </article>\n "]; } } // Merge in child terms for the current taxonomy term $children = taxonomy_get_children($tid); foreach ($children as $t) { $link = l($t->name, 'taxonomy/term/' . $t->tid); $items[] = ['title' => $t->name, 'summary' => "\n <article class=\"\">\n <h1>{$link}</h1>\n <p>{$t->description}</p>\n </article>\n "]; } usort($items, function ($a, $b) use($tid) { $map = [56 => ['Municipal Code' => 1, 'City Budget' => 2]]; if (array_key_exists($tid, $map)) { $a_in_map = array_key_exists($a['title'], $map[$tid]); $b_in_map = array_key_exists($b['title'], $map[$tid]); if ($a_in_map || $b_in_map) { if ($a_in_map && !$b_in_map) { return -1; } if ($b_in_map && !$a_in_map) { return 1;