本文整理汇总了PHP中field_get_items函数的典型用法代码示例。如果您正苦于以下问题:PHP field_get_items函数的具体用法?PHP field_get_items怎么用?PHP field_get_items使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了field_get_items函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: completeCSVertical
protected function completeCSVertical()
{
$order_line = field_get_items('commerce_order', $this->datasources["order"], 'commerce_line_items');
$line_item_ids[] = $order_line[0]['line_item_id'];
$line_item = commerce_line_item_load_multiple($line_item_ids);
$product_ids = array();
$tmp = field_get_items('commerce_line_item', $line_item[0], 'commerce_product');
$product_ids[] = $tmp[0]['product_id'];
$products = commerce_product_load_multiple($product_ids);
$item = $products[0];
if (property_exists($item, "csmdd32")) {
$datosCS["CSMDD32"] = $item->csmdd32[LANGUAGE_NONE][0]["value"];
}
return array_merge($this->getMultipleProductsInfo(), $datosCS);
}
示例2: getMultipleProductsInfo
protected function getMultipleProductsInfo()
{
$order_lines = field_get_items('commerce_order', $this->datasources["order"], 'commerce_line_items');
$line_item_ids = array();
foreach ($order_lines as $order_line) {
$line_item_ids[] = $order_line['line_item_id'];
}
$line_items = commerce_line_item_load_multiple($line_item_ids);
$product_ids = array();
$cant_prod = array();
foreach ($line_items as $line_item) {
$tmp = field_get_items('commerce_line_item', $line_item, 'commerce_product');
$cant_prod[$tmp[0]['product_id']] = round($line_item->quantity);
$product_ids[] = $tmp[0]['product_id'];
}
$products = commerce_product_load_multiple($product_ids);
$code = array();
$description = array();
$name = array();
$sku = array();
$total = array();
$quantity = array();
$unit = array();
foreach ($products as $item) {
$code[] = $this->getCategoryArray($item);
if (!empty($item->description)) {
$desc = $item->description;
} else {
$desc = $item->title;
}
$desc = strip_tags($desc);
$desc = TodoPago\Sdk::sanitizeValue($desc);
$desc = substr($desc, 0, 50);
$description[] = $desc;
$name[] = substr($item->title, 0, 250);
$sku[] = substr(empty($item->sku) ? $item->product_id : $item->sku, 0, 250);
$total[] = number_format(commerce_currency_amount_to_decimal($item->commerce_price[LANGUAGE_NONE][0]["amount"], $item->commerce_price[LANGUAGE_NONE][0]["currency_code"]) * $cant_prod[$item->product_id], 2, ".", "");
$quantity[] = $cant_prod[$item->product_id];
$unit[] = number_format(commerce_currency_amount_to_decimal($item->commerce_price[LANGUAGE_NONE][0]["amount"], $item->commerce_price[LANGUAGE_NONE][0]["currency_code"]), 2, ".", "");
}
$productsData = array('CSITPRODUCTCODE' => join("#", $code), 'CSITPRODUCTDESCRIPTION' => join("#", $description), 'CSITPRODUCTNAME' => join("#", $name), 'CSITPRODUCTSKU' => join("#", $sku), 'CSITTOTALAMOUNT' => join("#", $total), 'CSITQUANTITY' => join("#", $quantity), 'CSITUNITPRICE' => join("#", $unit));
return $productsData;
}
示例3: jeugdwerksupport_preprocess_node
/**
* Override or insert variables into the node template.
*/
function jeugdwerksupport_preprocess_node(&$variables)
{
$node = $variables['node'];
// Add template suggestions
if (!$variables['page']) {
if ($variables['teaser']) {
$variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__teaser';
$variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->nid . '__teaser';
$variables['theme_hook_suggestions'][] = 'node__teaser';
}
}
// Add class 'node-full'
if ($variables['view_mode'] == 'full' && node_is_page($node)) {
$variables['classes_array'][] = 'node-full';
}
// Set custom date format
$variables['date'] = format_date($node->created, 'custom', 'F jS Y');
// Add summary variable
if ($variables['view_mode'] == 'full') {
$items = field_get_items('node', $node, 'body', $node->language);
if ($items) {
// If there's a single summary, just set the summary variable
if (count($items) == 1) {
$variables['summary'] = $items[0]['summary'];
} else {
foreach ($items as $item) {
$variables['summary'][] = $item['summary'];
}
}
}
}
}
示例4: gavias_laikafood_format_comma_field
function gavias_laikafood_format_comma_field($field_category, $node, $limit = NULL)
{
if (module_exists('i18n_taxonomy')) {
$language = i18n_language();
}
$category_arr = array();
$category = '';
$field = field_get_items('node', $node, $field_category);
if (!empty($field)) {
foreach ($field as $item) {
$term = taxonomy_term_load($item['tid']);
if ($term) {
if (module_exists('i18n_taxonomy')) {
$term_name = i18n_taxonomy_term_name($term, $language->language);
// $term_desc = tagclouds_i18n_taxonomy_term_description($term, $language->language);
} else {
$term_name = $term->name;
//$term_desc = $term->description;
}
$category_arr[] = l($term_name, 'taxonomy/term/' . $item['tid']);
}
if ($limit) {
if (count($category_arr) == $limit) {
$category = implode(', ', $category_arr);
return $category;
}
}
}
}
$category = implode(', ', $category_arr);
return $category;
}
示例5: entityFindCandidate
/**
* {@inheritdoc}
*/
function entityFindCandidate($entity, $entity_type, $distinction_key)
{
$items = field_get_items($entity_type, $entity, $this->fieldKey);
if (is_array($items) && !empty($items)) {
return $this->fieldFindCandidate($items);
}
}
示例6: queryLoad
protected function queryLoad($ids)
{
$multifields = multifield_get_fields();
foreach (array_keys($multifields) as $field_name) {
$query = new EntityFieldQuery();
if ($ids) {
$query->fieldCondition($field_name, 'id', $ids, 'IN');
} else {
$query->fieldCondition($field_name, 'id', 0, '>');
}
if ($results = $query->execute()) {
$pseudo_entities = array();
$field = field_info_field($field_name);
foreach ($results as $entity_type => $entities) {
// Simply doing an entity load on the entities with multifield values
// will cause the cacheSet() from multifield_field_load() to get
// invoked.
$entities = entity_load($entity_type, array_keys($entities));
foreach ($entities as $entity) {
if ($items = field_get_items($entity_type, $entity, $field_name)) {
foreach ($items as $item) {
$pseudo_entities[$item['id']] = _multifield_field_item_to_entity($field['type'], $item);
}
}
}
}
$this->cacheSet($pseudo_entities);
}
}
return array_intersect_key($this->entityCache, drupal_map_assoc($ids, $ids));
}
示例7: ns_theme_dynamic_formatters_style
function ns_theme_dynamic_formatters_style($variables)
{
$output = '<div class="dynamic-formatters-group promo-group clearfix">';
$i = 0;
foreach ($variables['rows'] as $id => $row) {
$additional = $variables['view']->result[$id]->additional_info;
if (isset($additional['requiredcontext_entity:taxonomy_term_2'])) {
$term = $additional['requiredcontext_entity:taxonomy_term_2']->data;
$width = field_get_items('taxonomy_term', $term, 'field_ns_ch_web_width');
$width = $width[0]['value'];
$grid = '';
$no_margin = '';
if ($i > 0) {
$grid = 'grid-' . intval($width / 2);
if ($i % 2 == 0) {
$no_margin = 'omega';
} else {
$no_margin = 'alpha';
}
}
}
$output .= '<div class="promo promo-' . $i . ' ' . $grid . ' ' . $no_margin . ' clearfix">' . $row . '</div>';
$i++;
}
return $output . '</div>';
}
示例8: getRelatedPosts
function getRelatedPosts($ntype, $nid)
{
$nids = db_query("SELECT n.nid, title FROM {node} n WHERE n.status = 1 AND n.type = :type AND n.nid <> :nid ORDER BY RAND() LIMIT 0,2", array(':type' => $ntype, ':nid' => $nid))->fetchCol();
$nodes = node_load_multiple($nids);
$return_string = '';
if (!empty($nodes)) {
foreach ($nodes as $node) {
$field_image = field_get_items('node', $node, 'field_image_blog');
$return_string .= '<li class="item content-in col-md-6"><div class="widget-post-wrap">';
$return_string .= '<div class="thumb"><a href="' . url("node/" . $node->nid) . '">';
$return_string .= '<img src="' . file_create_url($node->field_image['und'][0]['uri']) . '" alt="' . $node->title . '">';
$return_string .= '</a></div>';
$return_string .= '<div class="article-content-wrap">';
$return_string .= '<h4 class="title"><a href="' . url("node/" . $node->nid) . '">';
$return_string .= $node->title . '</a></h4>';
$return_string .= '<div class="excerpt">' . substr($node->body['und'][0]['value'], 0, 100) . '...' . '</div>';
$return_string .= '<div class="meta-bottom">';
/* $return_string .= '<div class="post-cat"><span><i class="fa fa-folder"></i></span>'.strip_tags(render($content['field_blog_category']),'<a>').'</div>';*/
$return_string .= '<div class="post-date"><span><i class="fa fa-clock-o"></i></span>' . format_date($node->created, 'custom', 'M j,Y') . '</div>';
$return_string .= '<div class="meta-comment"><span><i class="fa fa-comments-o"></i></span><a href="' . url("node/" . $node->nid) . '">' . $node->comment_count . '</a></div>';
$return_string .= '</div></div>';
$return_string .= '<a class="bk-cover-link" href="' . url("node/" . $node->nid) . '"></a></div>';
$return_string .= '</li>';
}
}
return $return_string;
}
示例9: jollyness_format_comma_field
function jollyness_format_comma_field($field_category, $node, $limit = NULL)
{
$category_arr = array();
$field = field_get_items('node', $node, $field_category);
if (!empty($field)) {
foreach ($field as $item) {
$term = taxonomy_term_load($item['tid']);
if ($term) {
if (module_exists('i18n_taxonomy')) {
$term_name = i18n_taxonomy_term_name($term, $node->language);
} else {
$term_name = $term->name;
}
$category_arr[] = l($term_name, 'taxonomy/term/' . $item['tid']);
}
if ($limit) {
if (count($category_arr) == $limit) {
$category = implode(', ', $category_arr);
return $category;
}
}
}
}
$category = implode(', ', $category_arr);
return $category;
}
示例10: noreg_preprocess_node__sale_ad
function noreg_preprocess_node__sale_ad(&$variables)
{
// All node types but page
if ($variables['elements']['#view_mode'] != 'page') {
// Litter
if ($field_litter = field_get_items('node', $variables['node'], 'field_litter_id')) {
$node_litter = node_load($field_litter[0]['target_id']);
// Birthdate
if ($field_litter_birthdate = field_get_items('node', $node_litter, 'field_birthdate')) {
$variables['litter_birthdate'] = field_view_value('node', $node_litter, 'field_birthdate', $field_litter_birthdate[0], array('settings' => array('format_type' => 'custom_short')));
}
// Price per young
if ($field_litter_price_per_young = field_get_items('node', $node_litter, 'field_price_per_young')) {
$variables['litter_price_per_young'] = field_view_value('node', $node_litter, 'field_price_per_young', $field_litter_price_per_young[0]);
}
// Animal
if ($field_animal = field_get_items('node', $node_litter, 'field_animal_id')) {
$node_animal = node_load($field_animal[0]['target_id']);
// Breed
if ($field_breed = field_get_items('node', $node_animal, 'field_breed_id')) {
$variables['animal_breed'] = field_view_value('node', $node_animal, 'field_breed_id', $field_breed[0]);
}
}
}
// User
if ($node_creator = ha_user_get_raw_information($variables['user']->uid)) {
// Location
if (isset($node_creator['location'])) {
$variables['user_location'] = $node_creator['location'];
}
}
}
}
示例11: generate
/**
* Implements EditMetadataGeneratorInterface::generate().
*/
public function generate($entity_type, $entity, array $instance, $langcode, $view_mode)
{
$field_name = $instance['field_name'];
// Early-return if user does not have access.
$access = $this->accessChecker->accessEditEntityField($entity_type, $entity, $field_name);
if (!$access) {
return array('access' => FALSE);
}
// Early-return if no editor is available.
if (!_edit_is_extra_field($entity_type, $field_name)) {
$display = field_get_display($instance, $view_mode, $entity);
$formatter_type = field_info_formatter_types($display['type']);
$items = field_get_items($entity_type, $entity, $field_name, $langcode);
$items = $items === FALSE ? array() : $items;
$editor_id = $this->editorSelector->getEditor($formatter_type, $instance, $items);
} else {
// @see hook_edit_extra_fields_info()
$extra = edit_extra_field_info($entity_type, $field_name);
if (isset($extra['view mode dependent editor'][$view_mode])) {
$editor_id = $extra['view mode dependent editor'][$view_mode];
} else {
$editor_id = $extra['default editor'];
}
}
if (!isset($editor_id)) {
return array('access' => FALSE);
}
// Gather metadata, allow the editor to add additional metadata of its own.
if (!_edit_is_extra_field($entity_type, $field_name)) {
$label = $instance['label'];
} else {
$label = edit_extra_field_info($entity_type, $field_name, 'label');
}
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$metadata = array('label' => check_plain($label), 'access' => TRUE, 'editor' => $editor_id, 'aria' => t('Entity @type @id, field @field', array('@type' => $entity_type, '@id' => $id, '@field' => $label)));
if (!_edit_is_extra_field($entity_type, $field_name)) {
$editor = edit_editor_get($editor_id);
if (!empty($editor['metadata callback'])) {
if ($editor['file']) {
require_once $editor['file path'] . '/' . $editor['file'];
}
if (function_exists($editor['metadata callback'])) {
$custom_metadata = $editor['metadata callback']($instance, $items);
if (count($custom_metadata)) {
$metadata['custom'] = $custom_metadata;
}
}
}
// Allow the metadata to be altered.
$context = array('entity_type' => $entity_type, 'entity' => $entity, 'field' => $instance, 'items' => $items);
drupal_alter('edit_editor_metadata', $metadata, $editor_id, $context);
}
return $metadata;
}
示例12: ssd_preprocess_node
function ssd_preprocess_node(&$variables)
{
$node = $variables['node'];
$variables['title'] = check_plain($node->title);
if ($node->type == 'article') {
// Get only the first body summary for a module.
$body = field_get_items('node', $node, 'body');
$variables['summary'] = field_view_value('node', $node, 'body', $body[0], 'teaser');
$variables['metadata'] = field_view_field('node', $node, 'field_metadata', 'default');
}
}
示例13: fieldView
public function fieldView($node, $field, $view_mode = 'default')
{
if (!$node instanceof NodeInterface) {
return '';
}
if (!field_get_items('node', $node, $field)) {
return '';
}
$output = field_view_field('node', $node, $field, $view_mode);
return drupal_render($output);
}
示例14: fj16_preprocess_node
function fj16_preprocess_node(&$vars)
{
if ($vars['node']->type !== 'fj16_news_article') {
return;
}
$user = user_load($vars['node']->uid);
if ($user && $user->uid !== 0) {
$name = field_get_items('user', $user, 'field_name')[0]['value'];
$vars['user_realname'] = check_plain($name);
}
}
示例15: field_view_values
public function field_view_values($entity_type, $entity, $field_name, $display = array(), $langcode = NULL)
{
$items = field_get_items($entity_type, $entity, $field_name);
if ($items) {
$output = array();
foreach ($items as $item) {
$output[] = field_view_value($entity_type, $entity, $field_name, $item, $display, $langcode);
}
return $output;
}
}