当前位置: 首页>>代码示例>>PHP>>正文


PHP taxonomy_get_tree函数代码示例

本文整理汇总了PHP中taxonomy_get_tree函数的典型用法代码示例。如果您正苦于以下问题:PHP taxonomy_get_tree函数的具体用法?PHP taxonomy_get_tree怎么用?PHP taxonomy_get_tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了taxonomy_get_tree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: jollyness_preprocess_html

function jollyness_preprocess_html(&$vars)
{
    //Process portfolio color
    if ($portfolio_category = taxonomy_vocabulary_machine_name_load('portfolio_category')) {
        $terms = taxonomy_get_tree($portfolio_category->vid);
        $less = new lessc();
        $css = '';
        $color = '';
        $class = '';
        foreach ($terms as $t) {
            $term = taxonomy_term_load($t->tid);
            $class = drupal_html_class($t->name);
            if (!empty($term->field_color)) {
                foreach ($term->field_color as $v) {
                    $color = $v[0]['value'];
                    break;
                }
            }
            if ($color) {
                $css .= ".dexp-masonry-filter,.dexp-portfolio-filter{.{$class} span:before{background-color: {$color} !important;}}";
                $css .= ".{$class} .portfolio-item-overlay{background-color: rgba(red({$color}), green({$color}), blue({$color}), 0.7) !important;}";
            }
        }
        $css = $less->compile($css);
        drupal_add_css($css, array('type' => 'inline'));
    }
}
开发者ID:antoniodltm,项目名称:pinolguitars,代码行数:27,代码来源:template.php

示例2: getTaxonomyTermsAsSelectOptions

 /**
  * @param  \stdClass $config
  * @return array
  */
 protected function getTaxonomyTermsAsSelectOptions($config)
 {
     $answer = [];
     if (isset($config->vocabulary) && isset($config->level)) {
         /** @var \stdClass $vocabulary */
         if ($vocabulary = taxonomy_vocabulary_machine_name_load($config->vocabulary)) {
             $tree = $tree = taxonomy_get_tree($vocabulary->vid, 0, null, true);
             dpm($tree, "FLAT TREE");
             /*
             				if(count($terms) == 1) {
             					$term = array_pop($terms);
             					if(isset($term->description)) {
             						$answer = $term->description;
             						if($stripHtml) {
             							$answer = strip_tags($answer);
             						}
             					}
             				}*/
         } else {
             drupal_set_message("Vocabulary not found by name: " . $config->vocabulary, 'warning');
         }
     } else {
         drupal_set_message("Vocabulary or Level not set in config: " . json_encode($config), 'warning');
     }
     return $answer;
 }
开发者ID:adamjakab,项目名称:D7WebformEnhancer,代码行数:30,代码来源:WebformEnhancer.php

示例3: hook_draw_chart_alter

/**
 * Implements hook_draw_chart_alter().
 */
function hook_draw_chart_alter(&$settings)
{
    foreach ($settings as $chart) {
        if (isset($chart['chart']['chartCategory']) && !empty($chart['chart']['chartCategory'])) {
            // Geting the count result by vocabulary machine name.
            $voc = taxonomy_vocabulary_machine_name_load('categories');
            $tree = taxonomy_get_tree($voc->vid);
            $header = array();
            foreach ($tree as $term) {
                // Feeds the header with terms names.
                $header[] = $term->name;
                $query = db_select('taxonomy_index', 'ti');
                $query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
                // Feeding the terms with the node count.
                $terms[] = $query->countQuery()->execute()->fetchField();
            }
            $columns = array('Content per category');
            $rows = array($terms);
            // Replacing the data of the chart.
            $chart['chart']['chartCategory']['header'] = $header;
            $chart['chart']['chartCategory']['rows'] = $rows;
            $chart['chart']['chartCategory']['columns'] = $columns;
            // Adding a colors attribute to the pie.
            $chart['chart']['chartCategory']['options']['colors'] = array('red', '#004411');
        }
    }
}
开发者ID:LandPotential,项目名称:LandPKS_dev.landpotential.org_v2,代码行数:30,代码来源:google_chart_tools.api.php

示例4: _bootstrap_theme_category_contents

function _bootstrap_theme_category_contents($vocab_name)
{
    global $user;
    //$contents = bootstrap_theme_get_category_contents(NODE_PUBLISHED, $user);
    $output = '';
    $myvoc = taxonomy_vocabulary_machine_name_load($vocab_name);
    $tree = taxonomy_get_tree($myvoc->vid);
    $depth = 0;
    $output .= '<div>Vocabulary terms under <a href="' . base_path() . 'category/' . $vocab_name . '" class="category-title">' . $myvoc->name . '</a>. Click on term you want to search content for.</div>
				<div style="float:right;"><a href="' . base_path() . '" class="btn btn-primary form-submit">Back</a></div><br>';
    $output .= '<ul>';
    foreach ($tree as $term) {
        if ($term->depth > $depth) {
            $output .= '<ul>';
            $depth = $term->depth;
        }
        if ($term->depth < $depth) {
            $output .= '</ul>';
            $depth = $term->depth;
        }
        //$output .= '<li>' . l($term->name, 'taxonomy/term/' . $term->tid) . '</li>';
        $output .= '<li>' . l($term->name, 'taxonomy/term/' . $term->tid) . "<br>";
        $output .= '<div>' . $term->description . '</div></li>';
    }
    $output .= '</ul>';
    return $output;
}
开发者ID:episolve,项目名称:clasnetworkdev,代码行数:27,代码来源:page.category.php

示例5: build

 /**
  * Implements \Drupal\block\BlockBase::blockBuild().
  */
 public function build()
 {
     static $vocabularies, $terms;
     $items = array();
     $faq_settings = \Drupal::config('faq.settings');
     if (!$faq_settings->get('use_categories')) {
         return;
     }
     $moduleHandler = \Drupal::moduleHandler();
     if ($moduleHandler->moduleExists('taxonomy')) {
         if (!isset($terms)) {
             $terms = array();
             $vocabularies = Vocabulary::loadMultiple();
             $vocab_omit = array_flip($faq_settings->get('omit_vocabulary'));
             $vocabularies = array_diff_key($vocabularies, $vocab_omit);
             foreach ($vocabularies as $vocab) {
                 foreach (taxonomy_get_tree($vocab->vid) as $term) {
                     if (FaqHelper::taxonomyTermCountNodes($term->tid)) {
                         $terms[$term->name] = $term->tid;
                     }
                 }
             }
         }
         if (count($terms) > 0) {
             foreach ($terms as $name => $tid) {
                 $items[] = l($name, 'faq-page/' . $tid);
             }
         }
     }
     return array('#theme' => 'item_list', '#items' => $items, '#list_type' => $faq_settings->get('category_listing'));
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:34,代码来源:FaqCategoriesBlock.php

示例6: deleteVocabularyTerms

 /**
  * Deletes all terms of a vocabulary.
  *
  * @param $vid
  *   int a vocabulary vid.
  */
 protected function deleteVocabularyTerms($vid)
 {
     $tids = array();
     foreach (taxonomy_get_tree($vid) as $term) {
         $tids[] = $term->tid;
     }
     entity_delete_multiple('taxonomy_term', $tids);
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:14,代码来源:TermDevelGenerate.php

示例7: bootstrap_theme_get_taxonomy_vocabulary_category_options

function bootstrap_theme_get_taxonomy_vocabulary_category_options($taxonomy_vocabulary_id)
{
    $options = array();
    //$options[] = '<none>';
    foreach (taxonomy_get_tree($taxonomy_vocabulary_id) as $category) {
        $options[$category->tid] = $category->name;
    }
    return $options;
}
开发者ID:episolve,项目名称:clasnetworkdev,代码行数:9,代码来源:bootstrap_theme.api.php

示例8: mis_theme_get_all_categories_array

function mis_theme_get_all_categories_array()
{
    $categories = taxonomy_get_tree(5);
    $catArray = null;
    foreach ($categories as $cat) {
        $catArray[] = taxonomy_term_load($cat->tid);
    }
    return $catArray;
}
开发者ID:drupalviking,项目名称:mis_theme,代码行数:9,代码来源:template.php

示例9: getOptionsfrom

function getOptionsfrom($taxonomy)
{
    $terms = array();
    $myvoc = taxonomy_vocabulary_machine_name_load($taxonomy);
    $tree = taxonomy_get_tree($myvoc->vid);
    foreach ($tree as $term) {
        array_push($terms, $term->name);
    }
    return $terms;
}
开发者ID:nwpointer,项目名称:facultymodule,代码行数:10,代码来源:utilityFucntions.php

示例10: _taxonomy_options

function _taxonomy_options($machine_name, $default = '')
{
    $vocabulary = taxonomy_vocabulary_machine_name_load($machine_name);
    $tree = taxonomy_get_tree($vocabulary->vid);
    if (!empty($default)) {
        $options[0] = $default;
    } else {
        $options = array();
    }
    foreach ($tree as $item) {
        $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
    }
    return $options;
}
开发者ID:defrox,项目名称:bikespain,代码行数:14,代码来源:node--productos.tpl.php

示例11: exploreworld_preprocess_page

function exploreworld_preprocess_page(&$vars)
{
    $voc = taxonomy_vocabulary_machine_name_load('travel_destinations');
    $taxonomy = taxonomy_get_tree($voc->vid);
    $items = array();
    foreach ($taxonomy as $row) {
        $items[] = $row->name;
    }
    $vars['custom_item_list'] = theme('custom_item_list', array('items' => $items));
    $obj = menu_get_object();
    if (is_object($obj)) {
        $vars['theme_hook_suggestions'][] = 'page__' . $obj->type;
    }
}
开发者ID:tarasbondar,项目名称:drupallocal,代码行数:14,代码来源:template.php

示例12: hook_analytics_dashboard

/**
 * Implements hook_analytics_dashboard().
 */
function hook_analytics_dashboard()
{
    $voc = taxonomy_vocabulary_machine_name_load('categories');
    $tree = taxonomy_get_tree($voc->vid);
    $header = array();
    foreach ($tree as $term) {
        $header[] = $term->name;
        $query = db_select('taxonomy_index', 'ti');
        $query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
        $terms[] = $query->countQuery()->execute()->fetchField();
    }
    $columns = array('Ideas in category');
    $rows = array($terms);
    $settings = array();
    $settings['chart']['chartCategory'] = array('header' => $header, 'rows' => $rows, 'columns' => $columns, 'weight' => -10, 'chartType' => 'PieChart', 'options' => array('curveType' => "function", 'is3D' => TRUE, 'forceIFrame' => FALSE, 'title' => 'Ideas per category', 'width' => 500, 'height' => 300));
    return draw_chart($settings);
}
开发者ID:LandPotential,项目名称:LandPKS_dev.landpotential.org_v2,代码行数:20,代码来源:analytics_dashboard.api.php

示例13: testTaxonomyVocabularyTree

 /**
  * Test a taxonomy with terms that have multiple parents of different depths.
  */
 function testTaxonomyVocabularyTree()
 {
     // Create a new vocabulary with 6 terms.
     $vocabulary = $this->createVocabulary();
     $term = array();
     for ($i = 0; $i < 6; $i++) {
         $term[$i] = $this->createTerm($vocabulary);
     }
     // $term[2] is a child of 1 and 5.
     $term[2]->parent = array($term[1]->id(), $term[5]->id());
     $term[2]->save();
     // $term[3] is a child of 2.
     $term[3]->parent = array($term[2]->id());
     $term[3]->save();
     // $term[5] is a child of 4.
     $term[5]->parent = array($term[4]->id());
     $term[5]->save();
     /**
      * Expected tree:
      * term[0] | depth: 0
      * term[1] | depth: 0
      * -- term[2] | depth: 1
      * ---- term[3] | depth: 2
      * term[4] | depth: 0
      * -- term[5] | depth: 1
      * ---- term[2] | depth: 2
      * ------ term[3] | depth: 3
      */
     // Count $term[1] parents with $max_depth = 1.
     $tree = taxonomy_get_tree($vocabulary->id(), $term[1]->id(), 1);
     $this->assertEqual(1, count($tree), 'We have one parent with depth 1.');
     // Count all vocabulary tree elements.
     $tree = taxonomy_get_tree($vocabulary->id());
     $this->assertEqual(8, count($tree), 'We have all vocabulary tree elements.');
     // Count elements in every tree depth.
     foreach ($tree as $element) {
         if (!isset($depth_count[$element->depth])) {
             $depth_count[$element->depth] = 0;
         }
         $depth_count[$element->depth]++;
     }
     $this->assertEqual(3, $depth_count[0], 'Three elements in taxonomy tree depth 0.');
     $this->assertEqual(2, $depth_count[1], 'Two elements in taxonomy tree depth 1.');
     $this->assertEqual(2, $depth_count[2], 'Two elements in taxonomy tree depth 2.');
     $this->assertEqual(1, $depth_count[3], 'One element in taxonomy tree depth 3.');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:49,代码来源:TermUnitTest.php

示例14: getSettableOptions

 /**
  * {@inheritdoc}
  */
 public function getSettableOptions(AccountInterface $account = NULL)
 {
     if ($callback = $this->getSetting('options_list_callback')) {
         return call_user_func_array($callback, array($this->getFieldDefinition(), $this->getEntity()));
     } else {
         $options = array();
         foreach ($this->getSetting('allowed_values') as $tree) {
             if ($vocabulary = entity_load('taxonomy_vocabulary', $tree['vocabulary'])) {
                 if ($terms = taxonomy_get_tree($vocabulary->id(), $tree['parent'], NULL, TRUE)) {
                     foreach ($terms as $term) {
                         $options[$term->id()] = str_repeat('-', $term->depth) . $term->getName();
                     }
                 }
             }
         }
         return $options;
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:21,代码来源:TaxonomyTermReferenceItem.php

示例15: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $term = $this->entity;
     $vocab_storage = $this->entityManager->getStorage('taxonomy_vocabulary');
     $vocabulary = $vocab_storage->load($term->bundle());
     $parent = array_keys(taxonomy_term_load_parents($term->id()));
     $form_state['taxonomy']['parent'] = $parent;
     $form_state['taxonomy']['vocabulary'] = $vocabulary;
     $language_configuration = $this->moduleHandler->moduleExists('language') ? language_get_default_configuration('taxonomy_term', $vocabulary->id()) : FALSE;
     $form['langcode'] = array('#type' => 'language_select', '#title' => $this->t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $term->getUntranslated()->language()->id, '#access' => !empty($language_configuration['language_show']));
     $form['relations'] = array('#type' => 'details', '#title' => $this->t('Relations'), '#open' => $vocabulary->hierarchy == TAXONOMY_HIERARCHY_MULTIPLE, '#weight' => 10);
     // taxonomy_get_tree and taxonomy_term_load_parents may contain large
     // numbers of items so we check for taxonomy.settings:override_selector
     // before loading the full vocabulary. Contrib modules can then intercept
     // before hook_form_alter to provide scalable alternatives.
     if (!$this->config('taxonomy.settings')->get('override_selector')) {
         $parent = array_keys(taxonomy_term_load_parents($term->id()));
         $children = taxonomy_get_tree($vocabulary->id(), $term->id());
         // A term can't be the child of itself, nor of its children.
         foreach ($children as $child) {
             $exclude[] = $child->tid;
         }
         $exclude[] = $term->id();
         $tree = taxonomy_get_tree($vocabulary->id());
         $options = array('<' . $this->t('root') . '>');
         if (empty($parent)) {
             $parent = array(0);
         }
         foreach ($tree as $item) {
             if (!in_array($item->tid, $exclude)) {
                 $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
             }
         }
         $form['relations']['parent'] = array('#type' => 'select', '#title' => $this->t('Parent terms'), '#options' => $options, '#default_value' => $parent, '#multiple' => TRUE);
     }
     $form['relations']['weight'] = array('#type' => 'textfield', '#title' => $this->t('Weight'), '#size' => 6, '#default_value' => $term->getWeight(), '#description' => $this->t('Terms are displayed in ascending order by weight.'), '#required' => TRUE);
     $form['vid'] = array('#type' => 'value', '#value' => $vocabulary->id());
     $form['tid'] = array('#type' => 'value', '#value' => $term->id());
     if ($term->isNew()) {
         $form_state['redirect'] = current_path();
     }
     return parent::form($form, $form_state, $term);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:46,代码来源:TermForm.php


注:本文中的taxonomy_get_tree函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。