示例#1
1
 /**
  * {@inheritdoc}
  */
 function fieldFindCandidate(array $items)
 {
     $terms = array();
     foreach ($items as $item) {
         $terms[$item['tid']] = TRUE;
     }
     if (count($terms) > 1) {
         $walk = $terms;
         $visited = array();
         while (!empty($walk)) {
             $visited += $walk;
             foreach ($walk as $tid => $true) {
                 $parents = taxonomy_get_parents($tid);
                 unset($walk[$tid]);
                 foreach ($parents as $parent_tid => $parent) {
                     unset($terms[$parent_tid]);
                     if (!isset($visited[$parent_tid])) {
                         $walk[$parent_tid] = $parent;
                     }
                 }
             }
         }
     }
     // Return the path of the first found term, if any.
     foreach ($terms as $tid => $term_info) {
         $term = taxonomy_term_load($tid);
         if (!empty($term)) {
             $uri = entity_uri('taxonomy_term', $term);
             if (!empty($uri)) {
                 return $uri['path'];
             }
         }
     }
     return NULL;
 }
示例#2
0
/**
 * implements hook_preprocess_page()
 *
 **/
function odsherredweb_preprocess_page(&$variables)
{
    $current_theme = variable_get('theme_default', 'none');
    // Search form
    $variables['simple_navigation_search'] = module_invoke('search', 'block_view', 'search');
    // Navigation
    $variables['sidebar_borger'] = _bellcom_generate_menu('menu-indhold', 'sidebar');
    $variables['sidebar_erhverv'] = _bellcom_generate_menu('menu-erhverv', 'sidebar');
    $variables['sidebar_politik'] = _bellcom_generate_menu('menu-politik', 'sidebar');
    // Add the site structure term id to the page div
    $node = node_load(arg(1));
    if (is_object($node) && isset($node->field_os2web_spotbox_sitestruct)) {
        $termParents = taxonomy_get_parents($node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid']);
        $termId = 'tid-' . $node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid'];
        $termIdParent = "";
        if (!empty($termParents)) {
            $termIdParent = 'tid-' . key($termParents);
        }
        $variables['attributes_array']['class'] = $termIdParent . ' ' . $termId;
    }
    // Paths
    $variables['path_js'] = base_path() . drupal_get_path('theme', $current_theme) . '/js';
    $variables['path_img'] = base_path() . drupal_get_path('theme', $current_theme) . '/images';
    $variables['path_css'] = base_path() . drupal_get_path('theme', $current_theme) . '/css';
    $variables['path_font'] = base_path() . drupal_get_path('theme', $current_theme) . '/font';
}
示例#3
0
文件: Term.php 项目: pounard/yamm
 /**
  * (non-PHPdoc)
  * @see Entity::_constructDependencies()
  */
 protected function _constructDependencies($term)
 {
     // Add vocabulary dependency.
     $this->setData('vocabulary', $this->addDependency('vocabulary', $term->vid));
     // And parents.
     $parents = array();
     foreach (taxonomy_get_parents($term->tid) as $_term) {
         // This may happen, exclude the term itself.
         if ($_term->tid != $term->tid) {
             $parent_uuid = $this->addDependency('term', $_term->tid);
             $parents[$parent_uuid] = $parent_uuid;
         }
     }
     $this->setData('parents', $parents);
     // And relations.
     $related = array();
     foreach (taxonomy_get_related($term->tid) as $_term) {
         $related_uuid = $this->addDependency('term', $_term->tid);
         $related[$related_uuid] = $related_uuid;
     }
     $this->setData('relations', $related);
     // And synonyms.
     $this->setData('synonyms', taxonomy_get_synonyms($term->tid));
     // Do some cleanup that could break the restore process.
     unset($term->parents, $term->relations, $term->synonyms);
 }
示例#4
0
function phptemplate_preprocess_page(&$vars)
{
    $vars['tabs2'] = menu_secondary_local_tasks();
    if (module_exists('path')) {
        $alias = drupal_get_path_alias(str_replace('/edit', '', $_GET['q']));
        if ($alias != $_GET['q']) {
            $suggestions = array();
            $template_filename = 'page';
            foreach (explode('/', $alias) as $path_part) {
                $template_filename = $template_filename . '-' . $path_part;
                $suggestions[] = $template_filename;
            }
            $vars['template_files'] = array_merge((array) $suggestions, $vars['template_files']);
        }
    }
    //todo i think this can be deleted
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $termid = arg(2);
        $parent_term = taxonomy_get_parents($termid);
        if (key($parent_term) == EMAILS_TERM_ID) {
            $term = taxonomy_get_term($termid);
            $vars['template_file'] = 'page-taxonomy-term-emails';
        }
    }
}
示例#5
0
function bizutv_preprocess_node_video(&$vars, $hook)
{
    global $user;
    if ($vars['view_mode'] == 'full' && node_is_page($vars['node'])) {
        $channels = array();
        $parents = array_values(taxonomy_get_parents($vars['node']->field_channel['und'][0]['tid']));
        $channel = $vars['node']->field_channel['und'][0]['taxonomy_term'];
        if (count($parents)) {
            $channels[] = array('url' => url('taxonomy/term/' . $parents[0]->tid), 'name' => $parents[0]->name, 'tid' => $parents[0]->tid);
        }
        $channels[] = array('url' => url('taxonomy/term/' . $channel->tid), 'name' => $channel->name, 'tid' => $channel->tid);
        $name = bizutv_helper_get_user_name($vars['node']->uid);
        $node_view = node_view($vars['node']);
        $node = $vars['node'];
        $theme_vars['node'] = $node;
        global $ibtmedia_device;
        if ($ibtmedia_device == 'mobile' || $ibtmedia_device == 'tablet') {
            $vars['node']->video_player = theme('bizutv_mobile_player', $theme_vars);
        } else {
            $vars['node']->video_player = theme('bizutv_videoplayer', $theme_vars);
        }
        $vars['node']->display_name = l($name, 'user/' . $vars['node']->uid);
        $vars['node']->disqus_comment = render($node_view['disqus']);
        $vars['node']->rate_widget = render($node_view['rate_videos']);
        $vars['node']->autostart = 'true';
        $node_view['links']['statistics']['#links']['statistics_counter']['title'] = !empty($node_view['links']['statistics']['#links']['statistics_counter']['title']) ? str_replace('reads', 'views', $node_view['links']['statistics']['#links']['statistics_counter']['title']) : NULL;
        $vars['node']->reads = bizutv_video_get_node_hits($vars['node']->nid);
        $vars['taxonomy_parent'] = $channels;
        if ($vars['node']->field_stock) {
            foreach ($vars['node']->field_stock['und'] as $key => $stock_tag) {
                $vars['node']->field_stock['und'][$key]['taxonomy_term'] = taxonomy_term_load($stock_tag['tid']);
            }
        }
        $video_field = field_get_items('node', $node, 'field_video');
        $fid = !empty($video_field[0]['fid']) ? $video_field[0]['fid'] : NULL;
        $duration = null;
        if ($fid) {
            $vars['duration'] = bizutv_video_time_to_iso8601_duration($fid);
        }
        $vars['thumbnail_url'] = !empty($video_field[0]['thumbnailfile']->uri) ? file_create_url($video_field[0]['thumbnailfile']->uri) : NULL;
        if (module_exists('bizutv_email')) {
            if ($user->uid) {
                $send_email_form = drupal_get_form('bizutv_email_form', $node);
                $vars['send_email_form'] = drupal_render($send_email_form);
                $errors = form_get_errors();
            } else {
                $vars['send_email_form'] = '<p> <a href="/linkedin/check-session?lType=initiate" class="btn-sign-in"> Sign in or sign up</a> now! </p>';
            }
        }
    }
    $node_user = user_load($vars['node']->uid);
    if (in_array('company', $node_user->roles)) {
        $profile = bizutv_company_get_account_profile($vars['node']->uid);
        $field = field_get_items('profile2', $profile, 'field_website');
        $vars['company_url'] = !empty($field[0]['url']) ? $field[0]['url'] : NULL;
        $vars['company_title'] = !empty($field[0]['title']) ? $field[0]['title'] : NULL;
    }
}
function odsherredsub_preprocess_page(&$variables, $hook)
{
    // Add the site structure term id to the page div
    $node = node_load(arg(1));
    if (is_object($node) && isset($node->field_site_structure)) {
        $termParents = taxonomy_get_parents($node->field_site_structure[LANGUAGE_NONE][0]['tid']);
        $termId = 'tid-' . $node->field_site_structure[LANGUAGE_NONE][0]['tid'];
        $termIdParent = "";
        if (!empty($termParents)) {
            $termIdParent = 'tid-' . key($termParents);
        }
        $variables['attributes_array']['class'] = $termIdParent . ' ' . $termId;
    }
}
/**
 * Hierarchcal list of terms
 */
function category_generate_term_list($hierarchy)
{
    $items = array();
    foreach ($hierarchy as $term) {
        $title = $term->name;
        $item = l($title, 'catalog/' . $term->tid);
        if (!empty($term->children)) {
            $parent = taxonomy_get_parents($term->tid);
            if (!$parent) {
                $item .= '<span class="right head">' . l('+', '<front>') . '</span>';
            }
            $item .= commercebox_content_generate_term_list($term->children);
        }
        $items[] = $item;
    }
    return category_term_list(array('items' => $items, 'attributes' => array('class' => array('catalog'))));
}
示例#8
0
function ichado1_breadcrumb($variables)
{
    $title_move_flag = FALSE;
    $cur_path = current_path();
    if ($cur_path == 'catalog') {
        $variables['breadcrumb'] = array();
        return;
    }
    $cur_path_alias = drupal_get_path_alias($cur_path);
    $add_breadcrumb = drupal_get_title();
    if ($cur_path == 'cart' || preg_match('/^checkout\\/[\\d]+$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/complete$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/review$/', $cur_path) || preg_match('/^o-nas$/', $cur_path_alias) || preg_match('/^kontakty$/', $cur_path_alias) || preg_match('/^kak-zakazat-0$/', $cur_path_alias) || preg_match('/^oplata$/', $cur_path_alias) || preg_match('/^dostavka$/', $cur_path_alias) || preg_match('/^garantii-vozvrata$/', $cur_path_alias)) {
        $title_move_flag = TRUE;
        if (preg_match('/^checkout\\/[\\d]+$/', $cur_path)) {
            $add_breadcrumb = 'Оформление заказа';
            //@todo wrap in t()
        }
    }
    $breadcrumb = $variables['breadcrumb'];
    $item = menu_get_item();
    if ($item['path'] === 'catalog/%') {
        $term = taxonomy_term_load(intval($item['page_arguments'][2]));
        if (is_object($term)) {
            if (count(taxonomy_get_parents($term->tid)) == 0) {
                array_pop($breadcrumb);
            } else {
                array_pop($breadcrumb);
                array_pop($breadcrumb);
            }
        }
    }
    //Remove breadcrumbs on user login and registration pages
    if ($item['path'] === 'user/login' || $item['path'] === 'user/register') {
        $breadcrumb = array();
    }
    if (!empty($breadcrumb)) {
        if ($title_move_flag) {
            $breadcrumb[] = '<span>' . $add_breadcrumb . '</span>';
        }
        $output = '<div class="breadcrumb">' . implode('<span>&nbsp&nbsp→&nbsp&nbsp</span>', $breadcrumb) . '</div>';
        return $output;
    }
}
function cob_preprocess_page(&$vars)
{
    if (arg(0) == 'node') {
        $nid = arg(1);
        if (isset($vars['page']['content']['system_main']['nodes'][$nid])) {
            $node =& $vars['page']['content']['system_main']['nodes'][$nid];
            $bundle =& $node['#bundle'];
            if (isset($node['#node']->book)) {
                $vars['bookInfo'] = cob_book_info($node['#node']->book);
            }
        }
    } elseif (arg(0) == 'taxonomy') {
        $t =& $vars['page']['content']['system_main']['term_heading']['term']['#term'];
        $parents = taxonomy_get_parents($t->tid);
        if (count($parents)) {
            $t = (array) $t;
            $t['parent'] = current($parents);
            $t = (object) $t;
        }
    }
}
示例#10
0
/**
 * Custom function
 * Checks to see if this page is a country and returns the region.
 */
function _undp_is_country_page()
{
    if (arg(0) == "taxonomy" && arg(1) == "term") {
        // Check if this is a Region term.
        $term = taxonomy_term_load(arg(2));
        $vid = $term->vid;
        if ($vid == 5 && ($parents = taxonomy_get_parents($term->tid))) {
            return $parents;
        }
    }
}
示例#11
0
/**
 * 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;
    }
}
示例#12
0
function cca_preprocess_taxonomy_term(&$variables)
{
    $variables['tree_top'] = false;
    if ($term = $variables['elements']['#term']) {
        $parent = taxonomy_get_parents($term->tid);
        if (empty($parent)) {
            $variables['tree_top'] = true;
        }
    }
    $terms = taxonomy_get_tree(11, 0, 1);
    $i = 0;
    foreach ($terms as $term => $array) {
        if ($variables['tid'] == $array->tid) {
            $variables['pos'] = $i + 1;
            break;
        } else {
            $i++;
        }
    }
}
 *
 * To check for all available data within $info_split, use the code below.
 * @code
 *   <?php print '<pre>'. check_plain(print_r($info_split, 1)) .'</pre>'; ?>
 * @endcode
 *
 * @see template_preprocess()
 * @see template_preprocess_search_result()
 * @see template_process()
 */
$node = node_load($variables['result']['node']->entity_id);
$termId = '';
$termIdParent = '';
if (is_object($node) && !empty($node->field_site_structure)) {
    $termId = 'tid-' . $node->field_site_structure[LANGUAGE_NONE][0]['tid'];
    $termParents = taxonomy_get_parents($node->field_site_structure[LANGUAGE_NONE][0]['tid']);
    if (!empty($termParents)) {
        $termIdParent = 'tid-' . key($termParents);
    }
}
?>

<article class="search-result">
  <header>
    <h3 class="search-result-title <?php 
print $termIdParent . ' ' . $termId;
?>
"><a href="<?php 
print $url;
?>
"><?php 
 *
 * To check for all available data within $info_split, use the code below.
 * @code
 *   <?php print '<pre>'. check_plain(print_r($info_split, 1)) .'</pre>'; ?>
 * @endcode
 *
 * @see template_preprocess()
 * @see template_preprocess_search_result()
 * @see template_process()
 */
$node = node_load($variables['result']['node']->entity_id);
$termId = '';
$termIdParent = '';
if (is_object($node) && !empty($node->field_os2web_spotbox_sitestruct)) {
    $termId = 'tid-' . $node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid'];
    $termParents = taxonomy_get_parents($node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid']);
    if (!empty($termParents)) {
        $termIdParent = 'tid-' . key($termParents);
    }
}
?>

<article class="search-result">
  <header>
    <h3 class="search-result-title <?php 
print $termIdParent . ' ' . $termId;
?>
"><a href="<?php 
print $url;
?>
"><?php 
示例#15
0
文件: template.php 项目: radeus/2P
function ledger_my_folks($tid)
{
    $folks = taxonomy_get_parents(arg(2));
    foreach ($folks as $key => $value) {
        $region_path = "taxonomy/term/" . $value->tid;
        echo "<p>in " . l($value->name, $region_path) . "</p>";
    }
}
<?php 
// категория контактов
$term = taxonomy_term_load($node->field_contact_category['und'][0]['tid']);
$parents = taxonomy_get_parents($term->tid);
$address = '';
foreach ($parents as $parent) {
    $address = $parent->description;
}
?>
<div class="contact"> 
    <div class="contacts__name"><?php 
print $node->title;
?>
</div>
    <?php 
if (isset($node->field_leadtext['und'][0]['value'])) {
    ?>
        <div class="contacts__job"><?php 
    print $node->field_leadtext['und'][0]['value'];
    ?>
</div>
    <?php 
}
?>
    <?php 
if (isset($node->field_working_hours['und'][0]['value'])) {
    ?>
        <div class="contacts__working_hours">
            <span class="common-table__cell--header">Часы приема</span>
            <?php 
<?php

$sql = "select t5.tid, d1.name as l1, d2.name as l2, d3.name as l3, d4.name as l4, d5.name as l5 from {taxonomy_term_hierarchy} t1 inner join {taxonomy_term_hierarchy} t2 on t2.parent = t1.tid inner join {taxonomy_term_hierarchy} t3 on t3.parent = t2.tid inner join {taxonomy_term_hierarchy} t4 on t4.parent = t3.tid inner join {taxonomy_term_hierarchy} t5 on t5.parent = t4.tid  inner join taxonomy_term_data d5 on d5.tid = t5.tid inner join taxonomy_term_data d4 on d4.tid = t4.tid  inner join taxonomy_term_data d3 on d3.tid = t3.tid inner join taxonomy_term_data d2 on d2.tid = t2.tid inner join taxonomy_term_data d1 on d1.tid = t1.tid limit 100;";
$result = db_query($sql);
$data = $result->fetchAllAssoc('tid');
$output = array();
foreach ($data as $row) {
    $nids = taxonomy_select_nodes($row->tid, FALSE);
    if ($nids) {
        drush_log('Fixing ' . $row->tid . ': ' . $row->l1 . ' > ' . $row->l2 . ' > ' . $row->l3 . ' > ' . $row->l4 . ' > ' . $row->l5);
        $parent = taxonomy_get_parents($row->tid);
        $parent_id = reset(array_keys($parent));
        $nids = array_unique($nids);
        drush_print_r($nids);
        $nodes = node_load_multiple($nids);
        foreach ($nodes as $node) {
            if (isset($node->field_locations)) {
                foreach ($node->field_locations as $lang => $items) {
                    $parent_found = FALSE;
                    foreach ($items as $i => $item) {
                        // Check if parent exists.
                        if ($item['target_id'] == $parent_id) {
                            $parent_found = TRUE;
                        }
                    }
                    if ($parent_found) {
                        // Remove child.
                        foreach ($items as $i => $item) {
                            if ($item['target_id'] == $row->tid) {
                                unset($node->field_locations[$lang][$i]);
                                break;
/**
 * @file
 * This template is used to print a single field in a view.
 *
 * It is not actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the template is
 * perfectly okay.
 *
 * Variables available:
 * - $view: The view object
 * - $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.
 */
$output = '';
if (isset($row->field_field_major_minor_style_tr[0]['raw']['tid'])) {
    $tid = $row->field_field_major_minor_style_tr[0]['raw']['tid'];
    $parent = taxonomy_get_parents($tid);
    $parent = reset($parent);
    if (is_object($parent) && isset($parent->name)) {
        $output = $parent->name;
    }
}
print $output;
示例#19
0
$orderoutput = "";
$orderoutput .= $output . '?sort_by=field_price_value&sort_order=' . $sort_order . '"';
if ($sort_by == "price") {
    $orderoutput .= '  class="a" ';
}
$orderoutput .= '  >定价</a>';
print $orderoutput;
?>
								</li>
							</ul>
						</div>
	  <!--/产品列表排序 -->			
          <!--获取当前分类的父分类-->
          <?php 
$category = arg(1);
$parents = taxonomy_get_parents($category);
foreach ($parents as $id => $term) {
    $views_name = 'academic_filter';
    switch ($id) {
        case '277':
            $display_id = 'xueshu';
            break;
        case '256':
            $display_id = 'kaoshi';
            break;
        case '269':
            $display_id = 'shiyu';
            break;
        case '305':
            $display_id = 'duwu';
            break;
示例#20
0
/**
 * Override or insert variables into the html templates.
 *
 * @param $variables
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("html" in this case.)
 */
function elle_preprocess_html(&$variables, $hook)
{
    //variable initial
    $machine_name = '';
    $tid = '';
    $channel = '';
    $eng_title = '';
    $publish_time = '';
    $author = '';
    $current_term_eng = '';
    $keyword = '';
    $type = '';
    $content_id = '';
    //Add ELLE Custom MetaTag on node page
    if (arg(0) == 'node' && is_numeric(arg(1))) {
        $content_id = arg(1);
        $node = node_load(arg(1));
        $machine_name = isset($node->type) ? $node->type : NULL;
        switch ($machine_name) {
            case 'article':
                $type = 'new_dossier';
                $tid = $node->field_folder_taxonomy['und'][0]['target_id'];
                $eng_title = isset($node->field_english_title['und'][0]['value']) ? $node->field_english_title['und'][0]['value'] : NULL;
                $author = $node->name;
                $parent = taxonomy_get_parents($tid);
                $current_term = taxonomy_term_load($tid);
                $current_term_eng = isset($current_term->field_eng_name['und'][0]['value']) ? $current_term->field_eng_name['und'][0]['value'] : NULL;
                if (isset($node->field_tags['und'][0]['tid'])) {
                    $array = $node->field_tags['und'];
                    foreach ($array as $key => $value) {
                        $tid = $value['tid'];
                        $term_name = taxonomy_term_load($tid)->name;
                        $keyword = $keyword . $term_name . ', ';
                    }
                }
                $publish_time = Date('Y-m-d H:i:s', $node->created);
                foreach ($parent as $key => $value) {
                    $channel = isset($value->field_eng_name['und'][0]['value']) ? $value->field_eng_name['und'][0]['value'] : NULL;
                }
                break;
            case 'free_article':
                $type = 'free_article';
                $tid = $node->field_folder_taxonomy['und'][0]['target_id'];
                $eng_title = isset($node->field_english_title['und'][0]['value']) ? $node->field_english_title['und'][0]['value'] : NULL;
                $author = $node->name;
                $parent = taxonomy_get_parents($tid);
                $current_term = taxonomy_term_load($tid);
                $current_term_eng = isset($current_term->field_eng_name['und'][0]['value']) ? $current_term->field_eng_name['und'][0]['value'] : NULL;
                if (isset($node->field_tags['und'][0]['tid'])) {
                    $array = $node->field_tags['und'];
                    foreach ($array as $key => $value) {
                        $tid = $value['tid'];
                        $term_name = taxonomy_term_load($tid)->name;
                        $keyword = $keyword . $term_name . ', ';
                    }
                }
                $publish_time = Date('Y-m-d H:i:s', $node->created);
                foreach ($parent as $key => $value) {
                    $channel = isset($value->field_eng_name['und'][0]['value']) ? $value->field_eng_name['und'][0]['value'] : NULL;
                }
                break;
            default:
                $type = $machine_name;
        }
    } elseif (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        //頻道頁面ELLE Data Tag
        $tid = arg(2);
        $content_id = arg(2);
        $parent = taxonomy_get_parents($tid);
        $current_term = taxonomy_term_load($tid);
        $current_term_eng = isset($current_term->field_eng_name['und'][0]['value']) ? $current_term->field_eng_name['und'][0]['value'] : NULL;
        $keyword = isset($current_term->metatags['und']['keywords']['value']) ? $current_term->metatags['und']['keywords']['value'] : NULL;
        if ($parent) {
            foreach ($parent as $key => $value) {
                $channel = isset($value->field_eng_name['und'][0]['value']) ? $value->field_eng_name['und'][0]['value'] : NULL;
            }
        } else {
            $channel = isset($current_term->field_eng_name['und'][0]['value']) ? $current_term->field_eng_name['und'][0]['value'] : NULL;
        }
    }
    $html_head = array('data_type' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-type', 'content' => $type)), 'data_title' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-title', 'content' => $variables['head_title'])), 'data_pageName' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-pageName', 'content' => $channel . ':' . $current_term_eng . ':' . $eng_title)), 'data_channel' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-channel', 'content' => $channel)), 'data_internalsearch' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-internalsearch', 'content' => $keyword)), 'published_time' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-article:published_time', 'content' => $publish_time)), 'data_contentId' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-contentId', 'content' => $content_id)), 'data_author' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-author', 'content' => $author)), 'data_siteheir' => array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('property' => 'data-siteHeir', 'content' => $channel . ',' . $current_term_eng . ',' . $eng_title)));
    foreach ($html_head as $key => $data) {
        drupal_add_html_head($data, $key);
    }
}
    <div class="row header">

        <div class="col-sm-12">
            <h2><?php 
    echo $variables['view']->human_name;
    ?>
</h2>
        </div>

    </div>
    <div class="row">
        <div class="row-height">
<?php 
    $count = 0;
    foreach ($row->field_field_program_highlights as $idx => $field) {
        $parent = array_shift(taxonomy_get_parents($field['raw']['tid']));
        //TEMPORARY: ACADEMICS HAS BEEN "DISABLED" BY SES, BUT IT WILL RETURN
        if ($parent->tid != 474) {
            ?>
            <div class="col-xs-3 col-sm-2 col-md-1 col-md-height col-md-top">
                <?php 
            if (!empty($parent->field_highlights_icon)) {
                ?>
                <img class="img-responsive pull-right" src="<?php 
                echo file_create_url($parent->field_highlights_icon[LANGUAGE_NONE][0]['uri']);
                ?>
">
                <?php 
            }
            ?>
            </div>
示例#22
0
function learn_taxonomy_ancestry($tid)
{
    $p = taxonomy_get_parents($tid);
    $key = array_shift(array_keys($p));
    $c = taxonomy_get_tree($p[$key]->vid);
    $t_p = array();
    // sort the objects into families
    foreach ($c as $parents) {
        if ($parents->parents[0] == 0) {
            $t_p[$parents->tid] = (array) $parents;
        } else {
            $t_p[$parents->parents[0]]['children'][] = (array) $parents;
        }
    }
    /*
    $output = '<select id="fast-cat-change">';
    $output .= '<option value="null" selected="selected">---------------</option>';
    foreach($t_p as $item){
      if(isset($item['children'])){
        $output .= '<optgroup label="'.$item['name'].'">';
          foreach($item['children'] as $child){
            $link = base_path().drupal_get_path_alias("catalog/".$child['tid']);
            $output .= '<option value="'.$link.'">'.$child['name'].'</option>';
          }
        $output .= '</optgroup>';
      }else{
        $link = base_path().drupal_get_path_alias("catalog/".$item['tid']);
        $output .= '<option value="'.$link.'">'.$item['name'].'</option>';
      }
    }
    $output .= "</select>";
    */
    $output = '<select id="fast-cat-change">';
    $output .= '<option value="null" selected="selected">-- Categoria --</option>';
    foreach ($t_p as $item) {
        $act_cat = uc_catalog_get_page((int) $item['tid']);
        //echo "<pre>";
        //print_r($act_cat);
        //echo "</pre>";
        if (count($act_cat->children) > 0) {
            $output .= '<optgroup label="' . $act_cat->name . '">';
            foreach ($act_cat->children as $child) {
                if (!empty($child->nodes)) {
                    $link = base_path() . drupal_get_path_alias("catalog/" . $child->tid);
                    $output .= '<option value="' . $link . '">' . $child->name . '</option>';
                }
            }
            $output .= '</optgroup>';
        } else {
            $link = base_path() . drupal_get_path_alias("catalog/" . $act_cat->tid);
            if ($act_cat->tid != 38) {
                $output .= '<option value="' . $link . '">' . $act_cat->name . '</option>';
            }
        }
    }
    $output .= "</select>";
    // this should be replaced by calling all categories that belong to the cart
    //uc_catalog_get_page((int)$tid);
    return $output;
}