first commit
This commit is contained in:
42
components/com_fields/layouts/field/render.php
Normal file
42
components/com_fields/layouts/field/render.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_fields
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
if (!array_key_exists('field', $displayData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$field = $displayData['field'];
|
||||
$label = Text::_($field->label);
|
||||
$value = $field->value;
|
||||
$showLabel = $field->params->get('showlabel');
|
||||
$prefix = Text::plural($field->params->get('prefix'), $value);
|
||||
$suffix = Text::plural($field->params->get('suffix'), $value);
|
||||
$labelClass = $field->params->get('label_render_class');
|
||||
$valueClass = $field->params->get('value_render_class');
|
||||
|
||||
if ($value == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php if ($showLabel == 1) : ?>
|
||||
<span class="field-label <?php echo $labelClass; ?>"><?php echo htmlentities($label, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?>: </span>
|
||||
<?php endif; ?>
|
||||
<?php if ($prefix) : ?>
|
||||
<span class="field-prefix"><?php echo htmlentities($prefix, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="field-value <?php echo $valueClass; ?>"><?php echo $value; ?></span>
|
||||
<?php if ($suffix) : ?>
|
||||
<span class="field-suffix"><?php echo htmlentities($suffix, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?></span>
|
||||
<?php endif; ?>
|
||||
73
components/com_fields/layouts/fields/render.php
Normal file
73
components/com_fields/layouts/fields/render.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_fields
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
|
||||
|
||||
// Check if we have all the data
|
||||
if (!array_key_exists('item', $displayData) || !array_key_exists('context', $displayData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setting up for display
|
||||
$item = $displayData['item'];
|
||||
|
||||
if (!$item) {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = $displayData['context'];
|
||||
|
||||
if (!$context) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('.', $context);
|
||||
$component = $parts[0];
|
||||
$fields = null;
|
||||
|
||||
if (array_key_exists('fields', $displayData)) {
|
||||
$fields = $displayData['fields'];
|
||||
} else {
|
||||
$fields = $item->jcfields ?: FieldsHelper::getFields($context, $item, true);
|
||||
}
|
||||
|
||||
if (empty($fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
// If the value is empty do nothing
|
||||
if (!isset($field->value) || trim($field->value) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $field->name . ' ' . $field->params->get('render_class');
|
||||
$layout = $field->params->get('layout', 'render');
|
||||
$content = FieldsHelper::render($context, 'field.' . $layout, ['field' => $field]);
|
||||
|
||||
// If the content is empty do nothing
|
||||
if (trim($content) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$output[] = '<li class="field-entry ' . $class . '">' . $content . '</li>';
|
||||
}
|
||||
|
||||
if (empty($output)) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<ul class="fields-container">
|
||||
<?php echo implode("\n", $output); ?>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user