CoreFiles by mySites.guru
subfields.php64 lines, 1,446 bytes, from Joomla_4.0.0-beta5-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta4
md5
0f6ef4e3bd80acd6314a8a702de70a26
sha1
d7cbd5631ed801737945c3f085e8d58381c66336
sha256
4eef8cc98631b10b5a5bbc5732fad2b8046bc663fe1b7b1d1497e31b4a187c44
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Subfields
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

defined('_JEXEC') or die;

if (!$context || empty($field->subfields_rows))
{
	return;
}

$result = '';

// Iterate over each row that we have
foreach ($field->subfields_rows as $subfields_row)
{
	// Placeholder array to generate this rows output
	$row_output = array();

	// Iterate over each sub field inside of that row
	foreach ($subfields_row as $subfield)
	{
		$class   = trim($subfield->params->get('render_class', ''));
		$layout  = trim($subfield->params->get('layout', 'render'));
		$content = trim(
			FieldsHelper::render(
				$context,
				'field.' . $layout, // normally just 'field.render'
				array('field' => $subfield)
			)
		);

		// Skip empty output
		if ($content === '')
		{
			continue 1;
		}

		// Generate the output for this sub field and row
		$row_output[] = '<span class="field-entry' . ($class ? (' ' . $class) : '') . '">' . $content . '</span>';
	}

	// Skip empty rows
	if (count($row_output) == 0)
	{
		continue 1;
	}

	$result .= '<li>' . implode(', ', $row_output) . '</li>';
}
?>

<?php if (trim($result) != '') : ?>
	<ul class="fields-container">
		<?php echo $result; ?>
	</ul>
<?php endif; ?>

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.