Skip to main content
added 21 characters in body
Source Link
Sharky
  • 12k
  • 8
  • 23

In the template override, before the item loop query the database to get the data you need. This will return an array of objects indexed on core_content_id.

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_images', 'core_body')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');
$extraData = $db->setQuery($query)->loadObjectList('core_content_id');

Then, inside the item loop, you can use the data in a few different ways. You can merge the item with the data:

$item = (object) array_merge((array) $item, (array) $extraData[$item->core_content_id]);

Or you can assign the properties separately:

$item->images    = $extraData[$item->core_content_id]->core_images;
$item->introtext = $extraData[$item->core_content_id]->core_body;

Or you can use the data directly:

<?php // Display introtext ?>
<?php echo $extraData[$item->core_content_id]->core_body; ?>

<?php // Display intro image ?>
<?php $images = json_decode($extraData[$item->core_content_id]->core_images); ?>
<?php if (!empty($images->image_intro)) : ?>
    <img src="<?php echo htmlspecialchars($images->image_intro, ENT_QUOTES, 'UTF-8'); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_QUOTES, 'UTF-8'); ?>">
<?php endif; ?>

By the way, I can see this feature being implemented in core. If you agree, you can try submitting a feature request to the issue tracker.

In the template override, before the item loop query the database to get the data you need. This will return an array of objects indexed on core_content_id.

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_images', 'core_body')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');
$extraData = $db->setQuery($query)->loadObjectList('core_content_id');

Then, inside the item loop, you can use the data in a few different ways. You can merge the item with the data:

$item = (object) array_merge((array) $item, (array) $extraData[$item->core_content_id]);

Or you can assign the properties separately:

$item->images    = $extraData[$item->core_content_id]->core_images;
$item->introtext = $extraData[$item->core_content_id]->core_body;

Or you can use the data directly:

<?php // Display introtext ?>
<?php echo $extraData[$item->core_content_id]->core_body; ?>

<?php // Display intro image ?>
<?php $images = json_decode($extraData[$item->core_content_id]->core_images); ?>
<?php if (!empty($images->image_intro)) : ?>
    <img src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_QUOTES, 'UTF-8'); ?>">
<?php endif; ?>

By the way, I can see this feature being implemented in core. If you agree, you can try submitting a feature request to the issue tracker.

In the template override, before the item loop query the database to get the data you need. This will return an array of objects indexed on core_content_id.

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_images', 'core_body')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');
$extraData = $db->setQuery($query)->loadObjectList('core_content_id');

Then, inside the item loop, you can use the data in a few different ways. You can merge the item with the data:

$item = (object) array_merge((array) $item, (array) $extraData[$item->core_content_id]);

Or you can assign the properties separately:

$item->images    = $extraData[$item->core_content_id]->core_images;
$item->introtext = $extraData[$item->core_content_id]->core_body;

Or you can use the data directly:

<?php // Display introtext ?>
<?php echo $extraData[$item->core_content_id]->core_body; ?>

<?php // Display intro image ?>
<?php $images = json_decode($extraData[$item->core_content_id]->core_images); ?>
<?php if (!empty($images->image_intro)) : ?>
    <img src="<?php echo htmlspecialchars($images->image_intro, ENT_QUOTES, 'UTF-8'); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_QUOTES, 'UTF-8'); ?>">
<?php endif; ?>

By the way, I can see this feature being implemented in core. If you agree, you can try submitting a feature request to the issue tracker.

added 23 characters in body
Source Link
Sharky
  • 12k
  • 8
  • 23

In the template override, before the item loop query the database to get the data you need. This will return an array of objects indexed on core_content_id.

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_images', 'core_body')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');
$extraData = $db->setQuery($query)->loadObjectList('core_content_id');

Then, inside the item loop, you can use the data in a few different ways. You can merge the item with the data:

$item = (object) array_merge((array) $item, (array) $extraData[$item->core_content_id]);

Or you can assign the properties separately:

$item->images    = $extraData[$item->core_content_id]->core_images;
$item->introtext = $extraData[$item->core_content_id]->core_body;

Or you can use the data directly:

<?php // Display introtext ?>
<?php echo $extraData[$item->core_content_id]->core_body; ?>

<?php // Display intro image ?>
<?php $images = json_decode($extraData[$item->core_content_id]->core_images); ?>
<?php if (!empty($images->image_intro)) : ?>
    <img src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_QUOTES, 'UTF-8'); ?>">
<?php endif; ?>

By the way, I can see this feature being implemented in core. If you agree, you can try submitting a feature request to the issue tracker.

In the template override, before the item loop query the database to get the data you need. This will return an array of objects indexed on core_content_id.

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_images', 'core_body')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');
$extraData = $db->setQuery($query)->loadObjectList('core_content_id');

Then you can use the data in a few different ways. You can merge the item with the data:

$item = (object) array_merge((array) $item, (array) $extraData[$item->core_content_id]);

Or you can assign the properties separately:

$item->images = $extraData[$item->core_content_id]->core_images;
$item->introtext = $extraData[$item->core_content_id]->core_body;

Or you can use the data directly:

<?php // Display introtext ?>
<?php echo $extraData[$item->core_content_id]->core_body; ?>

<?php // Display intro image ?>
<?php $images = json_decode($extraData[$item->core_content_id]->core_images); ?>
<?php if (!empty($images->image_intro)) : ?>
    <img src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_QUOTES, 'UTF-8'); ?>">
<?php endif; ?>

By the way, I can see this feature being implemented in core. If you agree, you can try submitting a feature request to the issue tracker.

In the template override, before the item loop query the database to get the data you need. This will return an array of objects indexed on core_content_id.

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_images', 'core_body')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');
$extraData = $db->setQuery($query)->loadObjectList('core_content_id');

Then, inside the item loop, you can use the data in a few different ways. You can merge the item with the data:

$item = (object) array_merge((array) $item, (array) $extraData[$item->core_content_id]);

Or you can assign the properties separately:

$item->images    = $extraData[$item->core_content_id]->core_images;
$item->introtext = $extraData[$item->core_content_id]->core_body;

Or you can use the data directly:

<?php // Display introtext ?>
<?php echo $extraData[$item->core_content_id]->core_body; ?>

<?php // Display intro image ?>
<?php $images = json_decode($extraData[$item->core_content_id]->core_images); ?>
<?php if (!empty($images->image_intro)) : ?>
    <img src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_QUOTES, 'UTF-8'); ?>">
<?php endif; ?>

By the way, I can see this feature being implemented in core. If you agree, you can try submitting a feature request to the issue tracker.

Source Link
Sharky
  • 12k
  • 8
  • 23

In the template override, before the item loop query the database to get the data you need. This will return an array of objects indexed on core_content_id.

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_images', 'core_body')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');
$extraData = $db->setQuery($query)->loadObjectList('core_content_id');

Then you can use the data in a few different ways. You can merge the item with the data:

$item = (object) array_merge((array) $item, (array) $extraData[$item->core_content_id]);

Or you can assign the properties separately:

$item->images = $extraData[$item->core_content_id]->core_images;
$item->introtext = $extraData[$item->core_content_id]->core_body;

Or you can use the data directly:

<?php // Display introtext ?>
<?php echo $extraData[$item->core_content_id]->core_body; ?>

<?php // Display intro image ?>
<?php $images = json_decode($extraData[$item->core_content_id]->core_images); ?>
<?php if (!empty($images->image_intro)) : ?>
    <img src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_QUOTES, 'UTF-8'); ?>">
<?php endif; ?>

By the way, I can see this feature being implemented in core. If you agree, you can try submitting a feature request to the issue tracker.