本文整理汇总了PHP中taxonomy_term_load_multiple函数的典型用法代码示例。如果您正苦于以下问题:PHP taxonomy_term_load_multiple函数的具体用法?PHP taxonomy_term_load_multiple怎么用?PHP taxonomy_term_load_multiple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了taxonomy_term_load_multiple函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hook_taxonomy_menu_trails_get_paths
/**
* Map taxonomy term ids to their paths.
*
* This allows override of the default taxonomy/term/[tid] path for terms. As an
* example, this can be used to set the menu trail to a view where these terms
* are used, a specific node and so on.
*
* If you don't want to provide mappings for some terms then just skip them and
* Taxonomy Menu Trails will use default path for these terms.
*
* Results from multiple implementations are merged together.
*
* @param array $tids
* The list of taxonomy term ids.
* @param string $entity_type
* The type of entity passed to the next argument.
* @param object $entity
* The entity object, e.g. node.
* @param array $settings
* The taxonomy menu trails settings for this entity type.
*
* @return null|array
* List of mappings. Keys are tids and values can be:
* - string: single term path.
* - array: list of paths sorted by preference (the most preferred path should
* be the first).
*/
function hook_taxonomy_menu_trails_get_paths($tids, $entity_type, $entity, $settings)
{
// It is safe to load the same list of terms multiple times, because results
// are saved in static cache.
$terms = taxonomy_term_load_multiple($tids);
$paths = array();
foreach ($terms as $term) {
if ($term->tid == 987) {
// Specific term mapped to node and custom path. When selection method is
// first/last the first path existing in menu wins. So, node path will be
// preferred in this case.
$paths[$term->tid] = array('node/23', 'some/path');
continue;
}
switch ($term->vid) {
case 123:
// Some specific vocabulary mapped to a view.
$paths[$term->tid] = 'path/to/my/view' . $term->tid;
break;
case 456:
// Skip vocabulary. Terms will be mapped to default path.
break;
default:
// Map the rest to some default view.
$paths[$term->tid] = 'path/to/default/view/' . $term->tid;
}
}
return $paths;
}
示例2: genresProcess
public function genresProcess($tids)
{
$genres = taxonomy_term_load_multiple($tids);
if (empty($genres)) {
return NULL;
}
$element = [];
foreach ($genres as $genre) {
$path = entity_uri('taxonomy_term', $genre);
$element[] = array('name' => entity_label('taxonomy_term', $genre), 'path' => url($path['path'], $path['options']));
}
return $element;
}
示例3: createDrupalUser
/**
* @param string $roles
* User roles, separated by comma.
* @param TableNode $fields
* | Field machine name or label | Value |
*
* @throws \EntityMetadataWrapperException
* When user object cannot be saved.
* @throws \Exception
* When required fields are not filled.
*
* @example
* Then I am logged in as a user with "CRM Client" role and filled fields
* | Full name | Sergey Bondarenko |
* | Position | Developer |
* | field_crm_user_company | Propeople |
*
* @Given /^(?:|I am )logged in as a user with "([^"]*)" role(?:|s)(?:| and filled fields:)$/
*
* @user @api
*/
public function createDrupalUser($roles, TableNode $fields = null)
{
$user = $this->createUserWithRoles($roles);
if ($fields) {
$entity = self::entityWrapper($user->uid);
$required = self::getUserEntityFields('required');
// Fill fields. Field can be found by name or label.
foreach ($fields->getRowsHash() as $field_name => $value) {
$field_info = self::getUserEntityFieldInfo($field_name);
if (empty($field_info)) {
continue;
}
$field_name = $field_info['field_name'];
switch ($field_info['type']) {
case 'taxonomy_term_reference':
// Try to find taxonomy term by it name.
$terms = taxonomy_term_load_multiple([], ['name' => $value]);
if (!$terms) {
throw new \InvalidArgumentException(sprintf('Taxonomy term "%s" does no exist.', $value));
}
$value = key($terms);
break;
}
$entity->{$field_name}->set($value);
// Remove field from $required if it was there and filled.
if (isset($required[$field_name])) {
unset($required[$field_name]);
}
}
// Throw an exception when one of required fields was not filled.
if (!empty($required)) {
throw new \Exception(sprintf('The following fields "%s" are required and has not filled.', implode('", "', $required)));
}
$entity->save();
}
$this->loginUser();
}
示例4: cuemail_preprocess_node
/**
* Implements theme_preprocess_node().
*/
function cuemail_preprocess_node(&$vars)
{
$vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
$url = url('node/' . $vars['nid'], array('absolute' => TRUE, 'alias' => TRUE, 'https' => FALSE));
$vars['node_url'] = $url;
if ($vars['type'] == 'newsletter') {
if (!empty($vars['content']['field_newsletter_intro_image'])) {
$vars['content']['field_newsletter_intro_image'][0]['#image_style'] = 'email_medium';
}
$list = array();
foreach ($vars['content']['field_newsletter_section']['#items'] as $key => $item) {
$key_2 = key($vars['content']['field_newsletter_section'][$key]['entity']['field_collection_item']);
$articles = $vars['content']['field_newsletter_section'][$key]['entity']['field_collection_item'][$key_2]['field_newsletter_articles']['#items'];
foreach ($articles as $article) {
$node = node_load($article['target_id']);
$list[] = $node->title;
}
}
$newsletter_logo_image_style_uri = image_style_path('medium', $vars['newsletter_logo_uri']);
if (!file_exists($newsletter_logo_image_style_uri)) {
image_style_create_derivative(image_style_load('medium'), $vars['newsletter_logo_uri'], $newsletter_logo_image_style_uri);
}
$image_info = image_get_info($newsletter_logo_image_style_uri);
$vars['newsletter_logo_width'] = round($image_info['width'] * 0.46333);
$vars['newsletter_logo_height'] = round($image_info['height'] * 0.46333);
$vars['content']['list'] = theme('item_list', array('items' => $list, 'type' => 'ul', 'attributes' => array('class' => array('bullet-list'))));
}
if ($vars['type'] == 'article') {
if (!empty($vars['content']['field_article_thumbnail'][0])) {
$vars['content']['field_article_thumbnail'][0]['#path']['options']['absolute'] = TRUE;
}
if ($vars['view_mode'] == 'email_feature') {
$vars['content']['field_article_thumbnail'][0]['#image_style'] = 'email_feature_thumbnail';
}
if (isset($vars['field_article_categories'])) {
foreach ($vars['field_article_categories'] as $tid) {
if (isset($tid['tid'])) {
$tids[] = $tid['tid'];
}
}
}
if (isset($tids)) {
$terms = taxonomy_term_load_multiple($tids);
foreach ($terms as $term) {
if (isset($term->name)) {
$tag = $term->name;
if ($term->field_category_display[LANGUAGE_NONE][0]['value'] == 'show') {
if (!empty($term->field_category_term_page_link)) {
$new_tags[] = l($tag, $term->field_category_term_page_link[LANGUAGE_NONE][0]['url'], array('absolute' => TRUE, 'alias' => TRUE, 'https' => FALSE));
} else {
$new_tags[] = $tag;
}
}
}
}
$markup = implode(' ', $new_tags);
unset($vars['content']['field_article_categories']);
$vars['content']['field_article_categories'][0]['#markup'] = '<p>' . $markup . '</p>';
}
}
}
示例5: setTaxonomyTerms
/**
* Save specified taxonomy terms to vocabulary
*
* @param mixed $name
* A string or an array of strings
* @param int|string $voc
* (optionally) Vocabulary id/name
*
* @return mixed
* Fetched and inserted tids
*/
public static function setTaxonomyTerms($name, $voc = 0)
{
if (!is_numeric($voc)) {
$voc = self::getVidFromName($voc);
}
if (!is_array($name)) {
$name = array($name);
}
$tids = array();
$existing = self::getTaxonomyIdByName($name, $voc);
if (!empty($existing)) {
$existing = taxonomy_term_load_multiple($existing, array('vid' => $voc));
foreach ($existing as &$term) {
$tids[drupal_strtolower($term->name)] = $term->tid;
$term = NULL;
}
}
unset($existing);
foreach ($name as &$term) {
if (!isset($tids[drupal_strtolower($term)])) {
$t = new stdClass();
$t->vid = $voc;
$t->name = $term;
taxonomy_term_save($t);
$tids[$t->name] = $t->tid;
$t = NULL;
$term = NULL;
}
}
return $tids;
}
示例6: actionHome
public function actionHome()
{
if (!isset($_POST['tid'])) {
$tree = taxonomy_get_tree(2, 23, 50);
$tid = $tree[0]->tid;
} else {
$tid = $_POST['tid'];
}
//专题推送
$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'taxonomy_term')->fieldCondition('field_lanmu', 'tid', $tid)->execute();
$sorders = array();
if (isset($result['taxonomy_term'])) {
$termids = array_keys($result['taxonomy_term']);
$terms = taxonomy_term_load_multiple($termids);
foreach ($terms as $key => $term) {
if ($term->field_zorder['und'][0]['value']) {
$sorders[$term->field_zorder['und'][0]['value']] = $term->tid;
}
//$sorders[$term->field_field_zorder['und'][0]['value']]=$key;
}
}
$query = new EntityFieldQuery();
if (isset($_POST['lastnewsid'])) {
$query->entityCondition('entity_type', 'node')->fieldCondition('field_lanmu', 'tid', $tid)->fieldCondition('field_show', 'value', 1)->propertyCondition('status', 1)->propertyCondition('nid', $_POST['lastnewsid'], '<')->propertyOrderBy('sticky', 'DESC')->propertyOrderBy('vid', 'DESC')->range(0, 20);
} else {
$query->entityCondition('entity_type', 'node')->fieldCondition('field_lanmu', 'tid', $tid)->fieldCondition('field_show', 'value', 1)->propertyCondition('status', 1)->propertyOrderBy('sticky', 'DESC')->propertyOrderBy('vid', 'DESC')->range(0, 20);
}
$result = $query->execute();
$count = 1;
$newslists = array();
if (isset($result['node'])) {
$news_items_nids = array_keys($result['node']);
$nodes = node_load_multiple($news_items_nids);
foreach ($nodes as $node) {
if (!isset($_POST['lastnewsid'])) {
while (array_key_exists($count, $sorders)) {
$key = $sorders[$count];
$term = $terms[$key];
$special['newstype'] = 4;
//专题
$special['specialtype'] = $term->field__leix['und'][0]['value'];
$special['specialid'] = $term->tid;
$special['specialtitle'] = $term->name;
$special['specialimag'] = str_replace("public://", BigImg, $term->field_tux['und'][0]['uri']);
if ($term->field_link) {
$special['speciallink'] = $term->field_link['und'][0]['value'];
}
array_push($newslists, $special);
$count = $count + 1;
}
}
if ($node->type == 'multi') {
$newslist['newstype'] = 2;
//多图
$newslist['newstitle'] = $node->title;
$newslist['newsid'] = $node->nid;
$pics = array();
$field_tups = $node->field_tup['und'];
foreach ($field_tups as $field_tup) {
$pic = new pic();
$pic->pic = $field_tup['uri'];
$pic->pic = str_replace("public://", BigImg, $pic->pic);
array_push($pics, $pic);
}
$newslist['newspics'] = $pics;
array_push($newslists, $newslist);
} else {
if ($node->type == '_url') {
$url_news['newstype'] = 3;
//url链接新闻
$url_news['newstitle'] = $node->title;
$url_news['newsid'] = $node->nid;
$url_news['newsicon'] = $node->field_tux['und'][0]['uri'];
$url_news['newsicon'] = str_replace("public://", BigImg, $url_news['newsicon']);
$url_news['newslink'] = $node->field_link['und'][0]['value'];
array_push($newslists, $url_news);
} else {
$normal_news['newstype'] = 1;
//普通新闻
$normal_news['newstitle'] = $node->title;
$normal_news['newsid'] = $node->nid;
$field_image = $node->field_image;
$normal_news['newsicon'] = $field_image['und'][0]['uri'];
$normal_news['newsicon'] = str_replace("public://", ThumbnailImg, $normal_news['newsicon']);
$field_fubiaoti = $node->field_fubiaoti;
$normal_news['newssubtitle'] = $field_fubiaoti['und'][0]['value'];
$normal_news['newslabel'] = $node->field_label['und'][0]['value'];
$normal_news['comment_count'] = $node->comment_count;
array_push($newslists, $normal_news);
}
}
$count = $count + 1;
}
} else {
if (!isset($_POST['lastnewsid'])) {
foreach ($terms as $key => $term) {
$special['newstype'] = 4;
//专题
$special['specialtype'] = $term->field__leix['und'][0]['value'];
//.........这里部分代码省略.........
示例7: checkTaxonomyAutocompleteItems
public function checkTaxonomyAutocompleteItems($field_name, $testClass, $values)
{
$current_tids = call_user_func(array($this, "get" . Utils::makeTitleCase($field_name)));
if (!is_array($current_tids)) {
$term = taxonomy_term_load($current_tids);
$testClass->assertEquals($values, $term->name, "Values of the " . $field_name . " do not match.");
} else {
$terms = taxonomy_term_load_multiple($current_tids);
$term_labels = array();
foreach ($terms as $tid => $term) {
$term_labels[] = $term->name;
}
$testClass->assertEquals($values, $term_labels, "Values of the " . $field_name . " do not match.");
}
}
示例8: jjamerson_lc_preprocess_html
/**
* Implementing hook_preprocess_html()
*/
function jjamerson_lc_preprocess_html(&$variables)
{
/* Override head title on unique site sections: */
global $_bss_section_information;
$site_section = false;
if (isset($_bss_section_information['tid'])) {
$site_section_tid = $_bss_section_information['tid'];
$site_section = taxonomy_term_load($site_section_tid);
}
if (isset($node['language'])) {
$lang = $node['language'];
} else {
$lang = 'und';
}
if ($site_section && isset($site_section->field_base_url['und'][0]['value'])) {
// Check to see if this is the homepage of the site section. If so, just use the site section name.
// If not, use the current page title + the site section name.
if (drupal_get_path_alias() === $site_section->field_base_url['und'][0]['value']) {
$variables['head_title'] = $site_section->name;
if (empty($site_section->field_standalone['und'][0]['value'])) {
$variables['head_title'] .= ' | Berklee College of Music';
}
} else {
if (isset($site_section->field_standalone['und'][0]['value']) && $site_section->field_standalone['und'][0]['value']) {
$variables['head_title'] = $variables['head_title_array']['title'] . ' | ' . $site_section->name;
}
}
}
/* Override title on front page, because for some reason a pipe is being inserted into it */
if ($variables['is_front']) {
$variables['head_title'] = 'Berklee College of Music';
}
/* Add classes related to workbench moderation */
if (isset($variables['page']['content']['system_main']['nodes'])) {
$nodes = $variables['page']['content']['system_main']['nodes'];
if (count($nodes) === 2) {
$not_really_the_node = current($nodes);
$node = $not_really_the_node['#node'];
if (isset($node->workbench_moderation['published']) && $node->workbench_moderation['published']->vid === $node->vid) {
$workbench_moderation = $node->workbench_moderation['published'];
} else {
if (isset($node->workbench_moderation)) {
$workbench_moderation = $node->workbench_moderation['current'];
}
}
if (isset($workbench_moderation) && $workbench_moderation->state) {
$variables['classes_array'][] = 'workbench-state-' . $workbench_moderation->state;
if ($workbench_moderation->published) {
$variables['classes_array'][] = 'workbench-published';
} else {
$variables['classes_array'][] = 'workbench-unpublished';
}
}
}
}
/* Add tags on node as classes: */
if (isset($variables['page']['content']['system_main']['nodes'])) {
$nodes = $variables['page']['content']['system_main']['nodes'];
if (count($nodes) === 2) {
$not_really_the_node = current($nodes);
if (isset($not_really_the_node['#node'])) {
$node = $not_really_the_node['#node'];
if (isset($node->field_isotope_tags[$lang]) && count($node->field_isotope_tags[$lang])) {
$tids = array();
foreach ($node->field_isotope_tags[$lang] as $tid) {
$tids[] = $tid['tid'];
}
try {
$tags = taxonomy_term_load_multiple($tids);
foreach ($tags as $tag) {
$tag_name = strtolower($tag->name);
$tag_name = preg_replace('/[^a-z0-9 -]+/', '', $tag_name);
$tag_name = preg_replace('/\\s/', '-', $tag_name);
$tag_name = 'tagged-' . $tag_name;
$variables['classes_array'][] = " {$tag_name}";
}
} catch (Exception $e) {
// do nothing
}
}
}
}
}
if (isset($site_section->field_base_url) && isset($site_section->field_banner_image_large[$lang][0]['uri']) && $site_section->description) {
$site_section_home = $site_section->field_base_url[$lang][0]['value'];
if (drupal_get_path_alias() == $site_section_home) {
$variables['classes_array'][] = "lead-page";
}
}
/* Add a class to landing pages if the call-to-action field is empty: */
if (isset($node) && $node->type === 'landing' && count($node->field_call_to_action) === 0) {
$variables['classes_array'][] = 'empty-call-to-action';
}
/* Add a class to distinguish the Directory's starting page: */
if (function_exists('apachesolr_search_page_load')) {
$directory_search = apachesolr_search_page_load('directory');
// Get the path from the page info
//.........这里部分代码省略.........
示例9: render
<strong><?php
echo render($content['field_title']);
?>
</strong>
<?php
echo render($content['description']);
?>
</div>
</li>
</a>
</ul>
<?php
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'taxonomy_term')->propertyCondition('vid', $term->vid)->propertyOrderBy('weight');
$result = $query->execute();
if ($terms = taxonomy_term_load_multiple(array_keys($result['taxonomy_term']))) {
?>
<ol class="bjqs-markers h-centered">
<?php
foreach ($terms as $_term) {
$uri = entity_uri('taxonomy_term', $_term);
?>
<li><?php
echo l($_term->name, $uri['path'], $uri['options']);
?>
</li>
<?php
}
?>
</ol>
<?php
示例10: build_json
function build_json($markerCluster, $options)
{
$array_types = array();
$typologies = null;
if ($options['typology'] != null) {
$array_types = explode(',', $options['typology']);
$typologies = taxonomy_term_load_multiple($array_types);
} else {
// load taxonomy 'store_typology'
$taxonomies_vocab = taxonomy_vocabulary_get_names();
$typoTaxoVID = $taxonomies_vocab['store_typology']->vid;
// Load store types (taxonomy vid=2)
$type_options = array();
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'taxonomy_term', '=')->propertyCondition('vid', $typoTaxoVID, '=');
$result = $query->execute();
if (!empty($result)) {
$typologies = taxonomy_term_load_multiple(array_keys($result['taxonomy_term']));
}
}
$json = array();
global $base_url;
$path_icon_cluster = $base_url . '/' . drupal_get_path('module', 'storelocator_ws') . "/images/";
$index = 0;
$count = 0;
if ($options['macro'] != null && $options['macro'] == 'true') {
foreach ($markerCluster->clusters as $cluster) {
if (count($cluster->markers) > 1) {
$json['results'][] = buildClusterMarkers($cluster, $index, $path_icon_cluster);
$index++;
$count += count($cluster->markers);
} else {
//print_r(count($cluster->getMarkers()));
$json['results'][] = buildSimpleMarkers(reset($cluster->markers), $typologies);
$count++;
}
}
} else {
foreach ($markerCluster->markers as $marker) {
//print_r(count($cluster->getMarkers()));
$json['results'][] = buildSimpleMarkers($marker, $typologies);
$count++;
}
}
$json['count'] = $count;
return $json;
}
示例11: ardent_taxonomy_get_term_by_name
function ardent_taxonomy_get_term_by_name($name, $vocabulary = NULL)
{
$conditions = array('name' => trim($name));
if (isset($vocabulary)) {
$vocabularies = taxonomy_vocabulary_get_names();
if (isset($vocabularies[$vocabulary])) {
$conditions['vid'] = $vocabularies[$vocabulary]->vid;
} else {
// Return an empty array when filtering by a non-existing vocabulary.
return array();
}
}
return taxonomy_term_load_multiple(array(), $conditions);
}
示例12: createTermObjectsFromTids
/**
* @param $tids
*
* @return array
*/
public static function createTermObjectsFromTids($tids, $vocabulary = NULL, $false_on_invalid = TRUE)
{
$terms = taxonomy_term_load_multiple($tids);
$termObjects = array();
foreach ($tids as $tid) {
if (empty($terms[$tid])) {
if ($false_on_invalid) {
$termObjects[] = FALSE;
} else {
$termObjects = $tid;
}
continue;
}
$vocabulary = $terms[$tid]->vocabulary_machine_name;
$term_class = "RedTest\\entities\\TaxonomyTerm\\" . Utils::makeTitleCase($vocabulary);
$termObjects[] = new $term_class($tid);
}
return $termObjects;
}
示例13: t
<div class="om-right-block">
<h3 class="om-right-title"><?php
print t("Fontions Concernees");
?>
</h3>
<div class="om-right-content om-access">
<div class="field field-name-field-om-actuers field-type-taxonomy-term-reference field-label-hidden view-mode-full"><ul class="field-items">
<?php
$actuers = $node->field_om_actuers['und'];
for ($i = 0; $i < count($actuers); $i++) {
if ($i % 2 == 0) {
$class = "even";
} else {
$class = "odd";
}
$actuers_term = taxonomy_term_load_multiple(array($actuers[$i]['tid']));
print '<li class="field-item ' . $class . '">' . $actuers_term->name . '</li>';
}
?>
</ul>
</div>
</div>
</div>
<?php
}
?>
<?php
if (!empty($node->field_om_duration['und'][0]['value'])) {
?>
<div class="om-right-block">
<h3 class="om-right-title"><?php
示例14: array
<?php
if (isset($node->language)) {
$lang = $node->language;
} else {
$lang = 'und';
}
if (isset($node->field_isotope_tags[$lang]) && count($node->field_isotope_tags[$lang])) {
$tids = array();
foreach ($node->field_isotope_tags[$lang] as $tid) {
$tids[] = $tid['tid'];
}
try {
$tags = taxonomy_term_load_multiple($tids);
foreach ($tags as $tag) {
$tag_name = strtolower($tag->name);
$tag_name = preg_replace('/[^a-z0-9 -]+/', '', $tag_name);
$tag_name = preg_replace('/\\s/', '-', $tag_name);
$tag_name = 'tagged-' . $tag_name;
$classes .= " {$tag_name}";
}
} catch (Exception $e) {
}
}
?>
<div id="node-<?php
print $node->nid;
?>
" class="<?php
print $classes;
示例15: unity_lab_it_preprocess_paragraphs_item_service_categories_section
function unity_lab_it_preprocess_paragraphs_item_service_categories_section(&$vars, $hook)
{
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'taxonomy_term')->propertyCondition('vid', '3')->propertyOrderBy('weight')->range(0, 12);
//do not forget the semicolon at the end of the query conditions
$result = $query->execute();
if (!empty($result['taxonomy_term'])) {
// To load all terms.
$terms = taxonomy_term_load_multiple(array_keys($result['taxonomy_term']));
// To generate an options list.
foreach ($terms as $term) {
$taxTerm = array();
$targetLink = field_get_items('taxonomy_term', $term, 'field_target_link');
$targetLink = empty($targetLink[0]['url']) ? '' : $targetLink[0]['url'];
$taxTerm['target']['url'] = url($targetLink);
$icon = field_get_items('taxonomy_term', $term, 'field_icon_font_class');
$icon = empty($icon[0]['value']) ? '' : $icon[0]['value'];
$taxTerm['icon'] = $icon;
$taxTerm['title'] = $term->name;
$nodes = field_get_items('taxonomy_term', $term, 'field_related_nodes');
$link = array();
foreach ($nodes as $node) {
$nodeItem = node_load($node['target_id']);
$link['title'] = $nodeItem->title;
$link['url'] = url('node/' . $nodeItem->nid);
$taxTerm['links'][] = $link;
}
$vars['content']['items'][] = $taxTerm;
// To hook into i18n and everything else, use entity_label().
}
}
}