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


PHP taxonomy_get_term_by_name函数代码示例

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


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

示例1: prepare

 /**
  * Override Migration::prepare().
  *
  * Set the term parent for heirarchical terms
  *
  * @param $term
  * @param $row
  */
 public function prepare($term, $row)
 {
     // Handle og_vocab
     $vocab_name = $this->bundle;
     if (!($vocabulary = taxonomy_vocabulary_machine_name_load($vocab_name))) {
         // Create a new vocabulary
         $vocabulary = (object) array('name' => 'Meter categories for ' . $row->account_id, 'description' => 'Meter categories for ' . $row->account_id, 'machine_name' => $vocab_name);
         taxonomy_vocabulary_save($vocabulary);
     }
     // Create an OG-vocab and relate new vocabulary with OG.
     $account_id = $term->account_id['destid1'];
     $settings = array('cardinality' => 1, 'required' => TRUE);
     // Loop for all meter content-types and create og-vocabulary.
     $node_types = node_type_get_types();
     foreach ($node_types as $content_type) {
         if (strpos($content_type->type, '_meter') === FALSE) {
             // Not a meter type, skip.
             continue;
         }
         $og_vocab = og_vocab_create_og_vocab($vocabulary->vid, 'node', $content_type->type, OG_VOCAB_FIELD, $settings);
         $og_vocab->save();
     }
     og_vocab_relation_save($vocabulary->vid, 'node', $account_id);
     // Save vocabulary id.
     $term->vid = $vocabulary->vid;
     // Handle parent.
     $term->name = ucwords(trim($term->name));
     $parent = ucwords(trim($row->parent));
     $parent_term = taxonomy_get_term_by_name($parent, $vocab_name);
     $parent_term = reset($parent_term);
     if ($parent_term) {
         $term->parent = $parent_term->tid;
     }
 }
开发者ID:Gizra,项目名称:negawatt-server,代码行数:42,代码来源:NegawattMeterCategoryTermsBase.php

示例2: checkTerms

 public static function checkTerms($vocabName, $termName)
 {
     /*@param $vocabName
      *@param $termName
      *@return $tid
      */
     $vocab = taxonomy_vocabulary_machine_name_load($vocabName);
     $vid = $vocab->vid;
     //check term
     $checkTerm = taxonomy_get_term_by_name($termName, $vocabName);
     if (empty($checkTerm)) {
         $term = new stdClass();
         $term->name = $termName;
         $term->vid = $vid;
         taxonomy_term_save($term);
         $termArray = taxonomy_get_term_by_name($termName, $vocabName);
         $term = current($termArray);
         $tid = $term->tid;
         return $tid;
     } else {
         $term = current($checkTerm);
         $tid = $term->tid;
         return $tid;
     }
 }
开发者ID:rochester-rcl,项目名称:rcl-seward-transformations,代码行数:25,代码来源:letter_node_generator.php

示例3: externalPreviewsAreEnabledForFormat

 /**
  * @Given :provider previews are :setting for :format_name resources
  *
  * Changes variables in the database to enable or disable external previews
  */
 public function externalPreviewsAreEnabledForFormat($provider, $setting, $format_name)
 {
     $format = current(taxonomy_get_term_by_name($format_name, 'format'));
     $preview_settings = variable_get("dkan_dataset_format_previews_tid{$format->tid}", array());
     // If $setting was "enabled," the preview is turned on. Otherwise, it's
     // turned off.
     $preview_settings[$provider] = $setting == 'enabled' ? $provider : 0;
     variable_set("dkan_dataset_format_previews_tid{$format->tid}", $preview_settings);
 }
开发者ID:nucivic,项目名称:dkanextension,代码行数:14,代码来源:ResourceContext.php

示例4: expand

 /**
  * {@inheritdoc}
  */
 public function expand($values)
 {
     $return = array();
     foreach ($values as $name) {
         $terms = taxonomy_get_term_by_name($name, $this->getVocab());
         if (!$terms) {
             throw new \Exception(sprintf("No term '%s' exists.", $name));
         }
         $return[$this->language][] = array('tid' => array_shift($terms)->tid);
     }
     return $return;
 }
开发者ID:shrimala,项目名称:DrupalDriver,代码行数:15,代码来源:TaxonomyTermReferenceHandler.php

示例5: analysize_api_tags

/**
 * This function is used to verify api tags with cms tags and update its status 
 * $tag_names pass parameter as api tags
 * $tag_status mena its verified tags or unverified tag
 */
function analysize_api_tags($tag_names, $tag_status, $all_tids, $node)
{
    $tag_status = $tag_status == 'Verified' ? 'verified' : 'unverified';
    foreach ($tag_names as $tag_name) {
        $terms = taxonomy_get_term_by_name($tag_name, 'tags');
        if (empty($terms)) {
            $node->field_tags['und'][]['tid'] = custom_create_taxonomy_term($tag_name, 1, $tag_status);
            continue;
        }
        foreach ($terms as $key => $term) {
            $term->name = $tag_name;
            $term_id = $term->tid;
            if (!in_array($term_id, $all_tids)) {
                $node->field_tags['und'][]['tid'] = $term->tid;
            }
            update_tag_status($term, 'base', $tag_status);
        }
    }
    api_node_save($node);
}
开发者ID:sanjay9267,项目名称:dnaindia,代码行数:25,代码来源:topic_cron.php

示例6: createTip

function createTip($content)
{
    $term1 = taxonomy_get_term_by_name($content[0]);
    $term2 = taxonomy_get_term_by_name($content[1]);
    $tip = trim($content[2]);
    print "tip is: " . $content[0] . "," . $content[1] . "," . $content[2] . "\n";
    print "      : " . $term1[0]->tid . "," . $term2[0]->tid . "," . $tip . "\n";
    $terms = array($term1[0]->tid, $term2[0]->tid);
    $node = new stdClass();
    $node->type = 'quicktip';
    $node->title = $tip;
    $node->body = '';
    $node->teaser = '';
    $node->uid = 1;
    $node->language = 'en';
    $node->status = 0;
    $node->promote = 0;
    $node->field_ordinal = array(array('value' => $ordinal));
    $node->field_source = array(array('value' => $source));
    $node->taxonomy = $terms;
    node_save($node);
}
开发者ID:ericlink,项目名称:asthma-adherence-and-general-health-sms,代码行数:22,代码来源:asthma_quicktip_node_loader.php

示例7: expand

 /**
  * {@inheritdoc}
  */
 public function expand($values)
 {
     $result = array();
     $values = (array) $values;
     foreach ($values as $entry) {
         $terms = explode(',', $entry);
         foreach ($terms as $term) {
             // Try to split things out in order to find optional specified vocabs.
             $term_name_or_tid = '';
             $parts = explode(':', $term);
             if (count($parts) == 1) {
                 $term_name_or_tid = $term;
             } elseif (count($parts) == 2) {
                 $term_name_or_tid = $term;
             }
             if ($term_list = taxonomy_get_term_by_name($term_name_or_tid)) {
                 $term = reset($term_list);
                 $result[] = $term;
             }
         }
     }
     return $result;
 }
开发者ID:stovak,项目名称:DrupalDriver,代码行数:26,代码来源:TaxonomyHandler.php

示例8: set_article_categories

function set_article_categories($articleobj, $bundle, $categoryObj = NULL)
{
    $type = variable_get('brafton_existing_type');
    //Grabs the categories from the feed.
    if ($categoryObj != NULL) {
        $categories = array($categoryObj);
        $video_loader = true;
        $type = 'b_video';
    } else {
        $categories = $articleobj->getCategories();
        $video_loader = false;
    }
    switch ($type) {
        case 'b_news':
            $vocab = 'b_news_t';
            break;
        case 'b_video':
            $vocab = 'b_news_v';
            break;
        default:
            $info = field_info_field(variable_get('brafton_custom_taxonomy'));
            $vocab = $info['settings']['allowed_values'][0]['vocabulary'];
            break;
    }
    //Checks to see if the terms already exist in the Brafton Taxonomy Vocabulary.  If they do not, new terms are created.
    $i = 0;
    $brafton_vocabulary = taxonomy_vocabulary_machine_name_load($vocab);
    $vid = $brafton_vocabulary->vid;
    $cat_array = array();
    foreach ($categories as $category) {
        if ($video_loader) {
            $name = $categories[0]->name;
        } else {
            $name = get_category($categories, $i);
            $i = $i + 1;
        }
        $check_cat = taxonomy_get_term_by_name($name);
        $found = 0;
        foreach ($check_cat as $term) {
            if ($term->vid == $vid) {
                $tid = $term->tid;
                $found = 1;
            }
        }
        if ($found == 0) {
            $new_term = array('vid' => $vid, 'name' => $name);
            $new_term = (object) $new_term;
            taxonomy_term_save($new_term);
            $tid = $new_term->tid;
        }
        array_push($cat_array, $tid);
    }
    //Returns an array of valid term ids for the given article.
    return $cat_array;
}
开发者ID:ContentLEAD,项目名称:BraftonDrupal7Module,代码行数:55,代码来源:BraftonFunctions.php

示例9: termCreate

 /**
  * {@inheritdoc}
  */
 public function termCreate(\stdClass $term)
 {
     // Map vocabulary names to vid, these take precedence over machine names.
     if (!isset($term->vid)) {
         $vocabularies = \taxonomy_get_vocabularies();
         foreach ($vocabularies as $vid => $vocabulary) {
             if ($vocabulary->name == $term->vocabulary_machine_name) {
                 $term->vid = $vocabulary->vid;
             }
         }
     }
     if (!isset($term->vid)) {
         // Try to load vocabulary by machine name.
         $vocabularies = $this->taxonomyVocabularyLoadMultiple(array($term->vid));
         if (!empty($vocabularies)) {
             $vids = array_keys($vocabularies);
             $term->vid = reset($vids);
         }
     }
     // If `parent` is set, look up a term in this vocab with that name.
     if (isset($term->parent)) {
         $parent = \taxonomy_get_term_by_name($term->parent);
         if (!empty($parent)) {
             $parent = reset($parent);
             $term->parent = $parent->tid;
         }
     }
     if (empty($term->vid)) {
         throw new \Exception(sprintf('No "%s" vocabulary found.'));
     }
     // Attempt to decipher any fields that may be specified.
     $this->expandEntityFields('taxonomy_term', $term);
     // Protect against a failure from hook_taxonomy_term_insert() in pathauto.
     $current_path = getcwd();
     chdir(DRUPAL_ROOT);
     $term_array = (array) $term;
     \taxonomy_save_term($term_array);
     chdir($current_path);
     // Loading a term by name returns an array of term objects, but there should
     // only be one matching term in a testing context, so take the first match
     // by reset()'ing $matches.
     $matches = \taxonomy_get_term_by_name($term->name);
     $saved_term = reset($matches);
     return $saved_term;
 }
开发者ID:acbramley,项目名称:DrupalDriver,代码行数:48,代码来源:Drupal6.php

示例10: processAfterSubmit

 /**
  * This function is called after an EntityForm is submitted. Iterate over
  * $termNames variable and see which ones have taxonomy terms. These taxonomy
  * terms are created during form submission. Add these to global $entities
  * object so that they can be deleted later.
  *
  * @param Form $formObject
  *   Form object.
  * @param string $field_name
  *   Field name.
  *
  * @return array
  *   An array with 2 values:
  *   (1) $success: TRUE.
  *   (2) $msg: An empty string.
  */
 public static function processAfterSubmit(Form $formObject, $field_name)
 {
     if (self::isCckField($formObject, $field_name)) {
         $field_info = Field::getFieldInfo($field_name);
         $vocabulary = $field_info['settings']['allowed_values'][0]['vocabulary'];
         $class = "RedTest\\entities\\TaxonomyTerm\\" . Utils::makeTitleCase($vocabulary);
         if (sizeof(self::$termNames)) {
             global $entities;
             foreach (self::$termNames as $termName) {
                 $terms = taxonomy_get_term_by_name($termName, $vocabulary);
                 foreach ($terms as $tid => $term) {
                     // We are assuming that there will be only one term with the same
                     // name in a given vocabulary.
                     $entities['taxonomy_term'][$tid] = new $class($tid);
                     unset(self::$termNames[$termName]);
                 }
             }
         }
     }
     return new Response(TRUE, NULL, "");
 }
开发者ID:redcrackle,项目名称:redtest-core,代码行数:37,代码来源:TaxonomyTermReference.php

示例11: get_title_data

function get_title_data()
{
    $navigation_vocab = 'taxanavigation';
    $trail = menu_get_active_trail();
    $taxon = taxonomy_get_term_by_name($trail[2]['title'], $navigation_vocab);
    reset($taxon);
    return current($taxon);
}
开发者ID:mwagdi,项目名称:gbif-portal,代码行数:8,代码来源:template.php

示例12: termCreate

 /**
  * {@inheritdoc}
  */
 public function termCreate(\stdClass $term)
 {
     // Map vocabulary names to vid, these take precedence over machine names.
     if (!isset($term->vid)) {
         $vocabularies = \taxonomy_get_vocabularies();
         foreach ($vocabularies as $vid => $vocabulary) {
             if ($vocabulary->name == $term->vocabulary_machine_name) {
                 $term->vid = $vocabulary->vid;
             }
         }
     }
     if (!isset($term->vid)) {
         // Try to load vocabulary by machine name.
         $vocabularies = \taxonomy_vocabulary_load_multiple(FALSE, array('machine_name' => $term->vocabulary_machine_name));
         if (!empty($vocabularies)) {
             $vids = array_keys($vocabularies);
             $term->vid = reset($vids);
         }
     }
     // If `parent` is set, look up a term in this vocab with that name.
     if (isset($term->parent)) {
         $parent = \taxonomy_get_term_by_name($term->parent, $term->vocabulary_machine_name);
         if (!empty($parent)) {
             $parent = reset($parent);
             $term->parent = $parent->tid;
         }
     }
     if (empty($term->vid)) {
         throw new \Exception(sprintf('No "%s" vocabulary found.'));
     }
     // Attempt to decipher any fields that may be specified.
     $this->expandEntityFields('taxonomy_term', $term);
     \taxonomy_term_save($term);
     return $term;
 }
开发者ID:acbramley,项目名称:DrupalDriver,代码行数:38,代码来源:Drupal7.php

示例13: DeleteTerm

 /**
  * Delete a term in a given vocabulary.
  *
  * @param $term_name
  *  The name of the term.
  */
 public static function DeleteTerm($term_name)
 {
     $taxonomies = taxonomy_get_term_by_name($term_name);
     $term = reset($taxonomies);
     taxonomy_term_delete($term->tid);
 }
开发者ID:aleph-n,项目名称:opencholar,代码行数:12,代码来源:FeatureHelper.php

示例14: _panelize_gm_nodes

function _panelize_gm_nodes(&$variables)
{
    if (isset($variables['node'])) {
        $node = $variables['node'];
        $gmCTs = array('good_practice' => 'Good Practices', 'structure' => 'Structures', 'method_tool' => 'Methods & Tools', 'resource' => 'Other resources');
        $gmTopicCTs = array('structure', 'method_tool', 'resource');
        if (array_key_exists($node->type, $gmCTs) && isset($node->field_topic) && isset($node->field_topic['und'][0])) {
            $tId = $node->field_topic['und'][0]['tid'];
            $nodeTopic = taxonomy_term_load($tId);
            $tcId = $nodeTopic->field_topic_category['und'][0]['tid'];
            $gmTopicTerm = taxonomy_get_term_by_name('Gender Mainstreaming', 'topics');
            reset($gmTopicTerm);
            $gmTopicTermId = key($gmTopicTerm);
            $gmTopicCategoryTerm = taxonomy_get_term_by_name('Gender Mainstreaming', 'topic_categories');
            reset($gmTopicCategoryTerm);
            $gmTopicCategoryTermId = key($gmTopicCategoryTerm);
            // only nodes with GM topic category (good practices) or GM topic (structures, methods & tools, resources) should be panelized
            if ($tcId != $gmTopicCategoryTermId || in_array($node->type, $gmTopicCTs) && $tId != $gmTopicTermId) {
                return;
            }
            $countryName = $node->field_country['und'][0]['safe_value'];
            $countryUrl = strtolower(str_replace(" ", "-", $countryName));
            $panes = array('about' => 'About', 'structures' => 'Structures', 'laws-and-policies' => 'Laws & Policies', 'methods-and-tools' => 'Methods & Tools', 'good-practices' => 'Good Practices', 'resources' => 'Other resources');
            $main_html_prefix = '<div class="page-gender-mainstreaming-countries panelized-gm-node">' . '<h1 class="title" id="page-title"><span class="country">' . $countryName . '</span> ' . $gmCTs[$node->type] . '</h1>' . '<div class="content-header">' . '<h2 class="element-invisible">Primary tabs</h2>' . '<ul class="button-group">';
            foreach ($panes as $paneUrl => $paneName) {
                $active = $paneName == $gmCTs[$node->type];
                $main_html_prefix .= '<li' . ($active ? ' class="active"' : '') . '><a class="small button secondary' . ($active ? ' active' : '') . '" href="/gender-mainstreaming/countries/' . $countryUrl . '/' . $paneUrl . '">' . $paneName . '' . ($active ? '<span class="element-invisible">(active tab)</span>' : '') . '</a></li>';
            }
            $main_html_prefix .= '</ul></div></div>';
            $variables['main_html_prefix'] = $main_html_prefix;
        }
    }
}
开发者ID:EIGE,项目名称:www_staging,代码行数:33,代码来源:template.php

示例15: entity_metadata_wrapper

*/
?>
<!-- 	<b>Research Topics:</b>  -->
<?php 
// echo $result;
?>
<!-- <br> -->
<?php 
// }
?>

<?php 
$wrapper = entity_metadata_wrapper('node', $node);
foreach ($wrapper->field_people_spa as $i) {
    $values = $i->field_people_spa_title->value();
    $terms = taxonomy_get_term_by_name($i->field_people_spa_title->value());
    if (!empty($terms)) {
        $first_term = array_shift($terms);
        $first_term->tid;
    }
    $array_spa[] = "<a href=" . $base_url . "/taxonomy/term/" . rawurlencode(ucfirst($first_term->tid)) . ">" . ucfirst(trim($values)) . "</a>";
}
$result_spa = implode(", ", $array_spa);
if ($result_spa) {
    ?>
	<b>National Strategic Program Areas:</b>
	<?php 
    echo $result_spa;
    ?>
	<br>
<?php 
开发者ID:phpsubbarao,项目名称:test-core,代码行数:31,代码来源:page--people.tpl.php


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