本文整理汇总了PHP中field_get_items函数的典型用法代码示例。如果您正苦于以下问题:PHP field_get_items函数的具体用法?PHP field_get_items怎么用?PHP field_get_items使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了field_get_items函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:TodoPago,项目名称:Plugin-Drupal-Commerce,代码行数:15,代码来源:ControlFraudeDigitalgoods.php
示例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;
}
开发者ID:TodoPago,项目名称:Plugin-Drupal-Commerce,代码行数:43,代码来源:ControlFraude.php
示例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'];
}
}
}
}
}
开发者ID:Jeugdwerksupport,项目名称:drupal-theme,代码行数:35,代码来源:template.php
示例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;
}
开发者ID:ucaka,项目名称:forestway,代码行数:32,代码来源:functions.php
示例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);
}
}
开发者ID:radicalsuz,项目名称:fe,代码行数:10,代码来源:Abstract.php
示例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));
}
开发者ID:juanmnl07,项目名称:dandeleon,代码行数:31,代码来源:MultifieldEntityController.php
示例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>';
}
开发者ID:nodeone,项目名称:232,代码行数:26,代码来源:template.php
示例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;
}
开发者ID:bishopandco,项目名称:stlouishomesmag,代码行数:27,代码来源:template.php
示例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;
}
开发者ID:antoniodltm,项目名称:pinolguitars,代码行数:26,代码来源:template.php
示例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'];
}
}
}
}
开发者ID:bellcom,项目名称:noreg,代码行数:33,代码来源:template.php
示例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;
}
开发者ID:edysmp,项目名称:fullnessofdays,代码行数:57,代码来源:EditMetadataGenerator.php
示例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');
}
}
开发者ID:seefood,项目名称:ssd,代码行数:11,代码来源:template.php
示例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);
}
开发者ID:makinacorpus,项目名称:drupal-sf-dic,代码行数:11,代码来源:DrupalNodeExtension.php
示例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);
}
}
开发者ID:partio-scout,项目名称:fj16-web,代码行数:11,代码来源:template.php
示例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;
}
}
开发者ID:bangpound,项目名称:drupal-bundle,代码行数:11,代码来源:RenderExtension.php
示例16: getSchemaFields
/**
* Implements Drupal_RichSnippets_SchemaPreprocessorAbstract::getSchemaFields().
*/
public function getSchemaFields($schema)
{
$schema_fields = array();
$rdf_mappings = rich_snippets_get_rdf_schema_mappings($this->_entityType, $this->_bundle);
if (!empty($rdf_mappings[$schema])) {
foreach ($rdf_mappings[$schema] as $field_name) {
$items = field_get_items($this->_entityType, $this->_entity, $field_name);
$schema_fields[$field_name] = $items ? $items : array();
}
}
return $schema_fields;
}
开发者ID:drupalicus,项目名称:drupal-commons,代码行数:15,代码来源:NodeSchemaPreprocessor.php
示例17: hook_goals_completed_goal
/**
* Notification to modules that a goal is completed.
*
* @param int $goal_id
* Goal being completed.
* @param int $uid
* UserID of user completing the goal.
*/
function hook_goals_completed_goal($goal_id, $uid)
{
if (field_info_instance('goal', 'goal_userpoints', 'goal_bundle') && function_exists('userpoints_userpointsapi')) {
$goals = entity_load('goal', array($goal_id));
$goal = $goals[$goal_id];
$point_array = field_get_items('goal', $goal, 'goal_userpoints');
$points = $point_array[0]['value'];
if ($points) {
$params = array('uid' => $uid, 'points' => $points, 'description' => t('Goal @goal completed.', array('@goal' => $goal->title)));
userpoints_userpointsapi($params);
}
}
}
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:21,代码来源:goals.api.php
示例18: hook_date_ical_export_raw_event_alter
/**
* Modify an event's raw data.
*
* This hook is invoked after Date iCal has gathered all the data it will use
* to build an event object.
*
* @param array $event
* A reference to an associative array containing the event's raw data.
* @param object $view
* The view object that is being executed to render the iCal feed.
* @param array $context
* Depending on whether this event is being constructed using the Fields or
* Entity plugins, this context array will have different keys and values.
*
* Entity Plugin:
* - 'entity_type': The type of entity being rendered (e.g. 'node').
* - 'entity': The fully loaded entity being rendered.
* - 'language': The language code that indicates which translation of field
* data should be used.
*
* Fields Plugin:
* - 'row': The full Views row object being converted to an event.
* - 'row_index': The index into the query results for this view.
* - 'language': The language code that indicates which translation of field
* data should be used.
* - 'options': The Fields plugin options.
*/
function hook_date_ical_export_raw_event_alter(&$event, $view, $context)
{
// Example: adding a comment to an event from a simple
// textfield called 'field_comment' (using the Entity plugin).
if ($comments = field_get_items($context['entity_type'], $context['entity'], 'field_comment', $context['language'])) {
foreach ($comments as $comment) {
$event['comment'] = check_plain($comment['value']);
}
}
// Example: Retrieving information from additional fields in the View (using
// the Fields plugin).
$event['comment'] = $view->style_plugin->get_field($context['row_index'], 'field_comment');
}
开发者ID:cesardmoro,项目名称:openatrium-2-quickstart,代码行数:40,代码来源:date_ical.api.php
示例19: match
/**
* {@inheritdoc}
*
* @todo Update to new query API.
*/
public function match(ContactInterface $contact, $property = 'value')
{
$results = array();
$field_item = 'value';
$field = field_get_items('crm_core_contact', $contact, $rule->field_name);
$needle = isset($field[0]['value']) ? $field[0]['value'] : '';
if (!empty($needle)) {
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'crm_core_contact')->entityCondition('bundle', $contact->type)->entityCondition('entity_id', $contact->contact_id, '<>')->fieldCondition($rule->field_name, $field_item, $needle, $rule->operator);
$results = $query->execute();
}
return isset($results['crm_core_contact']) ? array_keys($results['crm_core_contact']) : $results;
}
开发者ID:jasonruyle,项目名称:crm_core,代码行数:18,代码来源:Date.php
示例20: hook_date_ical_feed_event_render_alter
/**
* Modify a structured event before it is rendered to iCal format.
*
* This hook is invoked after the Date iCal module has generated its
* representation of the event and allows you to modify or add to the
* representation. Use this hook to set values of iCal fields that are supported
* but have no values mapped into them by default.
*
* @param $event
* An associative array representation of the iCal event. This will be used by
* the Date iCal rendering system to create an entry in an iCal feed.
* @param $view
* The view object that is being executed to render the iCal feed.
* @param $context
* An associative array of context, with the following keys and values:
* - 'entity_type': The type of entity being rendered, 'node', 'user' etc.
* - 'entity': The fully loaded entity being rendered.
* - 'language': The language code that indicates which translation of field
* data should be used.
*/
function hook_date_ical_feed_event_render_alter(&$event, $view, $context)
{
// Simple example adding the location to a rendered event from a simple
// textfield called 'field_location'.
$entity_type = $context['entity_type'];
$entity = $context['entity'];
$language = $context['language'];
if ($locations = field_get_items($entity_type, $entity, 'field_location', $language)) {
foreach ($locations as $location) {
$event['location'] = check_plain($location['value']);
}
}
}
开发者ID:teodyseguin,项目名称:website,代码行数:33,代码来源:date_ical.api.php
注:本文中的field_get_items函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论