本文整理汇总了PHP中taxonomy_term_load_multiple函数的典型用法代码示例。如果您正苦于以下问题:PHP taxonomy_term_load_multiple函数的具体用法?PHP taxonomy_term_load_multiple怎么用?PHP taxonomy_term_load_multiple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了taxonomy_term_load_multiple函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:charlie59,项目名称:etypegoogle2.com,代码行数:56,代码来源:taxonomy_menu_trails.api.php
示例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;
}
开发者ID:adam-s,项目名称:954live,代码行数:13,代码来源:LivesearchArtists__1_0.php
示例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();
}
开发者ID:spheresh,项目名称:behat-drupal-propeople-context,代码行数:58,代码来源:UserContext.php
示例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>';
}
}
}
开发者ID:CuBoulder,项目名称:cu_newsletter_bundle,代码行数:64,代码来源:template.php
示例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;
}
开发者ID:vml-cmcelwain,项目名称:drupPink,代码行数:42,代码来源:feed_import_filter.inc.php
示例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'];
//.........这里部分代码省略.........
开发者ID:dingruoting,项目名称:tydaily,代码行数:101,代码来源:NewsController_before+ads.php
示例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.");
}
}
开发者ID:vishalred,项目名称:redtest-core-pw,代码行数:15,代码来源:Entity.php
示例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
//.........这里部分代码省略.........
开发者ID:jsongberklee,项目名称:jjamerson_lc,代码行数:101,代码来源:template.php
示例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
开发者ID:sockol,项目名称:md,代码行数:31,代码来源:taxonomy-term--product-type.tpl.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;
}
开发者ID:singhneeraj,项目名称:fr-store,代码行数:47,代码来源:gmaps-api.php
示例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);
}
开发者ID:phpsubbarao,项目名称:test-core,代码行数:14,代码来源:template.php
示例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;
}
开发者ID:redcrackle,项目名称:redtest-core,代码行数:24,代码来源:TaxonomyTerm.php
示例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
开发者ID:singhneeraj,项目名称:im-portal,代码行数:31,代码来源:im_features_om_print_preview.tpl.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;
开发者ID:jsongberklee,项目名称:dp7-theme-jjamerson-for-lc,代码行数:31,代码来源:node.tpl.php
示例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().
}
}
}
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:32,代码来源:template-paragraphs.php
示例16: _taxonomy_field
function _taxonomy_field($name, $vocab_name, $caption, $subtype, $active, $require, $card)
{
$vocab = taxonomy_vocabulary_machine_name_load($vocab_name);
$items = array();
if (!empty($vocab)) {
$terms = taxonomy_term_load_multiple(_get_term_id_array_by_vid($vocab->vid));
foreach ($terms as $tid => $term) {
$items[] = array('id' => $tid, 'text' => $term->name);
}
}
$max = $card;
if ($card == FIELD_CARDINALITY_UNLIMITED) {
$max = 0;
}
$attr = '';
if (!$active) {
$attr .= ' disabled';
}
if ($subtype == 'category' || $subtype == 'tag') {
$taxon_field = array('name' => $name, 'type' => 'enum', 'require' => $require, 'options' => array('items' => $items, 'max' => $max, 'openOnFocus' => true, 'markSearch' => true), 'html' => array('caption' => $caption, 'attr' => $attr));
if ($subtype == 'tag') {
$taxon_field['options']['onNew'] = 'function(event) { event.item.style = "background-color: rgb(255, 232, 232); border: 1px solid red;";}';
}
} else {
// boolean
$taxon_field = array('name' => $name, 'type' => 'toggle', 'require' => $require, 'html' => array('caption' => $caption));
}
return $taxon_field;
}
开发者ID:318io,项目名称:318-io,代码行数:29,代码来源:editcol.form_model.php
示例17: hook_field_formatter_prepare_view
/**
* Allow formatters to load information for field values being displayed.
*
* This should be used when a formatter needs to load additional information
* from the database in order to render a field, for example a reference field
* which displays properties of the referenced entities such as name or type.
*
* This hook is called after the field type's own hook_field_prepare_view().
*
* Unlike most other field hooks, this hook operates on multiple entities. The
* $entities, $instances and $items parameters are arrays keyed by entity ID.
* For performance reasons, information for all available entities should be
* loaded in a single query where possible.
*
* @param $entity_type
* The type of $entity.
* @param $entities
* Array of entities being displayed, keyed by entity ID.
* @param $field
* The field structure for the operation.
* @param $instances
* Array of instance structures for $field for each entity, keyed by entity
* ID.
* @param $langcode
* The language the field values are to be shown in. If no language is
* provided the current language is used.
* @param $items
* Array of field values for the entities, keyed by entity ID.
* @param $displays
* Array of display settings to use for each entity, keyed by entity ID.
*
* @return
* Changes or additions to field values are done by altering the $items
* parameter by reference.
*/
function hook_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays)
{
$tids = array();
// Collect every possible term attached to any of the fieldable entities.
foreach ($entities as $id => $entity) {
foreach ($items[$id] as $delta => $item) {
// Force the array key to prevent duplicates.
$tids[$item['tid']] = $item['tid'];
}
}
if ($tids) {
$terms = taxonomy_term_load_multiple($tids);
// Iterate through the fieldable entities again to attach the loaded term
// data.
foreach ($entities as $id => $entity) {
$rekey = FALSE;
foreach ($items[$id] as $delta => $item) {
// Check whether the taxonomy term field instance value could be loaded.
if (isset($terms[$item['tid']])) {
// Replace the instance value with the term data.
$items[$id][$delta]['taxonomy_term'] = $terms[$item['tid']];
} else {
unset($items[$id][$delta]);
$rekey = TRUE;
}
}
if ($rekey) {
// Rekey the items array.
$items[$id] = array_values($items[$id]);
}
}
}
}
开发者ID:rlugojr,项目名称:livereload-examples,代码行数:68,代码来源:field.api.php
示例18: bootstrap_theme_dashboard_contribute_create_form_submit
function bootstrap_theme_dashboard_contribute_create_form_submit(&$form, &$form_state)
{
global $user;
$contribution = new stdClass();
$contribution->type = NODE_TYPE_CLAS_CONTRIBUTOR;
$contribution->status = NODE_NOT_PUBLISHED;
$contribution->language = LANGUAGE_NONE;
$contribution->uid = $user->uid;
$term = taxonomy_term_load($form_state['values']['cno_learning_object_type']);
$termname = $term->name;
if (!empty($form_state['values']['cno_associated_materials'])) {
$file = file_load($form_state['values']['cno_associated_materials']);
} else {
$file = file_managed_file_save_upload($form['cno_associated_materials']);
}
if (!empty($form_state['values']['cnob_photo'])) {
$photo = file_load($form_state['values']['cnob_photo']);
} else {
$photo = file_managed_file_save_upload($form['cnob_photo']);
}
if ($termname == 'Audio') {
if (!empty($form_state['values']['cno_lobj_res_audio'])) {
$audio_file = file_load($form_state['values']['cno_lobj_res_audio']);
//$fname_arr = explode("://",$audio_file->uri);
//file_move($audio_file, "public://".$fname_arr[1], FILE_EXISTS_RENAME);
$contribution->field_cnob_learn_obj_res_audio[$contribution->language][0] = array('fid' => $audio_file->fid, 'display' => 1);
} else {
$audio_file = file_managed_file_save_upload($form['cno_lobj_res_audio']);
}
}
/*if (!empty($form_state['values']['cno_lobj_res_video'])) {
$video_file = file_load($form_state['values']['cno_lobj_res_video']);
$contribution->field_cnob_learn_obj_res_video[$contribution->language][0] = array('fid' => $video_file->fid,'display' => 1);
} else {
$video_file = file_managed_file_save_upload($form['cno_lobj_res_video']);
}*/
if ($termname == 'Document') {
if (!empty($form_state['values']['cno_lobj_res_document'])) {
$doc_file = file_load($form_state['values']['cno_lobj_res_document']);
$contribution->field_cnob_learn_obj_res_doc[$contribution->language][0] = array('fid' => $doc_file->fid, 'display' => 1);
} else {
$doc_file = file_managed_file_save_upload($form['cno_lobj_res_document']);
}
}
if ($termname == 'Link') {
if (!empty($form_state['values']['cno_lobj_res_link'])) {
$res_link = $form_state['values']['cno_lobj_res_link'];
} else {
$res_link = '';
}
$contribution->field_cnob_learn_obj_res_link[$contribution->language][0]['value'] = $res_link;
}
$contribution->title = $form_state['values']['title'];
$contribution->body[$contribution->language][0]['value'] = $form_state['values']['body'];
$contribution->field_cnob_user_type[$contribution->language][0]['value'] = $form_state['values']['cno_type'];
$contribution->field_cnob_category[$contribution->language][0]['tid'] = $form_state['values']['cno_category'];
$contribution->field_cnob_learning_object_type[$contribution->language][0]['tid'] = $form_state['values']['cno_learning_object_type'];
if ($termname == 'Video') {
$contribution->field_cnob_learn_obj_res_video[$contribution->language][0]['video_url'] = $form_state['values']['cno_lobj_res_video'];
}
$contribution->field_cnob_area_of_study[$contribution->language][0]['tid'] = $form_state['values']['cno_area_of_study'];
$contribution->field_cnob_grade_level[$contribution->language][0]['tid'] = $form_state['values']['cno_grade_level'];
$contribution->field_cnob_expiration_date[$contribution->language][0]['value'] = date('Y-m-d', strtotime($form_state['values']['expiration_date']));
$contribution->field_cnob_collections[$contribution->language][0]['nid'] = $form_state['values']['og_group_ref'];
$contribution->og_group_ref[$contribution->language][0]['target_id'] = $form_state['values']['og_group_ref'];
$contribution->field_cnob_content_area[$contribution->language][0] = array('tid' => $form_state['values']['cno_content_area']);
$contribution->group_content_access[$contribution->language][0]['value'] = OG_CONTENT_ACCESS_PRIVATE;
$contribution->cnob_content_area[$contribution->language][0]['value'] = OG_CONTENT_ACCESS_PRIVATE;
//$contribution->field_cnob_relevant_standards[$contribution->language][0]['tid'] = $form_state['values']['cno_relevant_standards'];
$contribution->field_cnob_lesson_plan[$contribution->language][0]['value'] = $form_state['values']['lesson_plan'];
$contribution->field_cnob_assigned_badge[$contribution->language][0]['value'] = $form_state['values']['cno_badge'];
if ($file) {
$contribution->field_cnob_associated_materials[$contribution->language][0] = array('fid' => $file->fid, 'display' => 1);
}
if ($photo) {
$contribution->field_cnob_photo[$contribution->language][0] = array('fid' => $photo->fid, 'display' => 1);
}
$contribution->field_cnob_comments[$contribution->language][0]['value'] = $form_state['values']['comments'];
//////Tags////
$tags = $form_state['values']['tags'];
$typed_terms = drupal_explode_tags($tags);
$tags_vocabulary = taxonomy_vocabulary_load(TAXONOMY_VOCABULARY_ID_TAGS);
$value_tags = array();
foreach ($typed_terms as $typed_term) {
if ($possibilities = taxonomy_term_load_multiple(array(), array('name' => trim($typed_term), 'vid' => array(TAXONOMY_VOCABULARY_ID_TAGS)))) {
$term = array_pop($possibilities);
} else {
$vocabulary = $tags_vocabulary;
$term = array('tid' => 'autocreate', 'vid' => $vocabulary->vid, 'name' => $typed_term, 'vocabulary_machine_name' => $vocabulary->machine_name);
}
$value_tags[] = (array) $term;
}
$contribution->field_cnob_tags[$contribution->language] = $value_tags;
//////Tags////
//////Relevant Standards//
|
请发表评论