[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_fields/layouts/fields/ -> render.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_fields
   6   *
   7   * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
  14  
  15  // Check if we have all the data
  16  if (!array_key_exists('item', $displayData) || !array_key_exists('context', $displayData)) {
  17      return;
  18  }
  19  
  20  // Setting up for display
  21  $item = $displayData['item'];
  22  
  23  if (!$item) {
  24      return;
  25  }
  26  
  27  $context = $displayData['context'];
  28  
  29  if (!$context) {
  30      return;
  31  }
  32  
  33  $parts     = explode('.', $context);
  34  $component = $parts[0];
  35  $fields    = null;
  36  
  37  if (array_key_exists('fields', $displayData)) {
  38      $fields = $displayData['fields'];
  39  } else {
  40      $fields = $item->jcfields ?: FieldsHelper::getFields($context, $item, true);
  41  }
  42  
  43  if (empty($fields)) {
  44      return;
  45  }
  46  
  47  $output = array();
  48  
  49  foreach ($fields as $field) {
  50      // If the value is empty do nothing
  51      if (!isset($field->value) || trim($field->value) === '') {
  52          continue;
  53      }
  54  
  55      $class = $field->name . ' ' . $field->params->get('render_class');
  56      $layout = $field->params->get('layout', 'render');
  57      $content = FieldsHelper::render($context, 'field.' . $layout, array('field' => $field));
  58  
  59      // If the content is empty do nothing
  60      if (trim($content) === '') {
  61          continue;
  62      }
  63  
  64      $output[] = '<li class="field-entry ' . $class . '">' . $content . '</li>';
  65  }
  66  
  67  if (empty($output)) {
  68      return;
  69  }
  70  ?>
  71  <ul class="fields-container">
  72      <?php echo implode("\n", $output); ?>
  73  </ul>


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer