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


PHP PodsForm::value方法代码示例

本文整理汇总了PHP中PodsForm::value方法的典型用法代码示例。如果您正苦于以下问题:PHP PodsForm::value方法的具体用法?PHP PodsForm::value怎么用?PHP PodsForm::value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PodsForm的用法示例。


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

示例1: field

 /**
  * Return the value for a field.
  *
  * If you are getting a field for output in a theme, most of the time you will want to use display() instead.
  *
  * This function will return arrays for relationship and file fields.
  *
  * @param string|array $name The field name, or an associative array of parameters
  * @param boolean $single (optional) For tableless fields, to return the whole array or the just the first item, or an associative array of parameters
  * @param boolean $raw (optional) Whether to return the raw value, or to run through the field type's display method, or an associative array of parameters
  *
  * @return mixed|null Value returned depends on the field type, null if the field doesn't exist, false if no value returned for tableless fields
  * @since 2.0
  * @link http://pods.io/docs/field/
  */
 public function field($name, $single = null, $raw = false)
 {
     global $sitepress;
     $defaults = array('name' => $name, 'orderby' => null, 'single' => $single, 'params' => null, 'in_form' => false, 'raw' => $raw, 'raw_display' => false, 'display' => false, 'get_meta' => false, 'output' => null, 'deprecated' => false, 'args' => array());
     if (is_array($name) || is_object($name)) {
         $defaults['name'] = null;
         $params = (object) array_merge($defaults, (array) $name);
     } elseif (is_array($single) || is_object($single)) {
         $defaults['single'] = null;
         $params = (object) array_merge($defaults, (array) $single);
     } elseif (is_array($raw) || is_object($raw)) {
         $defaults['raw'] = false;
         $params = (object) array_merge($defaults, (array) $raw);
     } else {
         $params = (object) $defaults;
     }
     if ($params->in_form) {
         $params->output = 'ids';
     } elseif (null === $params->output) {
         $params->output = $this->do_hook('field_related_output_type', 'arrays', $this->row, $params);
     }
     if (in_array($params->output, array('id', 'name', 'object', 'array', 'pod'))) {
         $params->output .= 's';
     }
     // Support old $orderby variable
     if (null !== $params->single && is_string($params->single) && empty($params->orderby)) {
         pods_deprecated('Pods::field', '2.0', 'Use $params[ \'orderby\' ] instead');
         $params->orderby = $params->single;
         $params->single = false;
     }
     if (null !== $params->single) {
         $params->single = (bool) $params->single;
     }
     if (is_array($params->name) || strlen(trim($params->name)) < 1) {
         return null;
     }
     $params->name = trim($params->name);
     $params->full_name = $params->name;
     $value = null;
     if (isset($this->row_override[$params->name])) {
         $value = $this->row_override[$params->name];
     }
     if (false === $this->row()) {
         if (false !== $this->data()) {
             $this->fetch();
         } else {
             return $value;
         }
     }
     if ($this->data->field_id == $params->name) {
         if (isset($this->row[$params->name])) {
             return $this->row[$params->name];
         } elseif (null !== $value) {
             return $value;
         }
         return 0;
     }
     $tableless_field_types = PodsForm::tableless_field_types();
     $simple_tableless_objects = PodsForm::field_method('pick', 'simple_objects');
     $params->traverse = array();
     if (in_array($params->name, array('_link', 'detail_url')) || in_array($params->name, array('permalink', 'the_permalink')) && in_array($this->pod_data['type'], array('post_type', 'media'))) {
         if (0 < strlen($this->detail_page)) {
             $value = get_home_url() . '/' . $this->do_magic_tags($this->detail_page);
         } elseif (in_array($this->pod_data['type'], array('post_type', 'media'))) {
             $value = get_permalink($this->id());
         } elseif ('taxonomy' == $this->pod_data['type']) {
             $value = get_term_link($this->id(), $this->pod_data['name']);
         } elseif ('user' == $this->pod_data['type']) {
             $value = get_author_posts_url($this->id());
         } elseif ('comment' == $this->pod_data['type']) {
             $value = get_comment_link($this->id());
         }
     }
     $field_data = false;
     $field_type = false;
     $first_field = explode('.', $params->name);
     $first_field = $first_field[0];
     if (isset($this->fields[$first_field])) {
         $field_data = $this->fields[$first_field];
         $field_type = 'field';
     } elseif (isset($this->pod_data['object_fields']) && !empty($this->pod_data['object_fields'])) {
         if (isset($this->pod_data['object_fields'][$first_field])) {
             $field_data = $this->pod_data['object_fields'][$first_field];
             $field_type = 'object_field';
         } else {
//.........这里部分代码省略.........
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:101,代码来源:Pods.php


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