I am creating an override in DP calendar and would like to display a custom field created in DP Calendar inside the module. The field type is 'URL' thus I would like it to be a clickable link. I have been unable to find any documentation as to how I can do this.
The below code is the module override. The link I would like to replace with the custom field is the Register link. The name of the custom field is 'reglink':
<?php
/**
* @package DPCalendar
* @author Digital Peak http://www.digital-peak.com
* @copyright Copyright (C) 2007 - 2019 Digital Peak. All rights reserved.
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
if (!$events) {
echo JText::_('MOD_DPCALENDAR_UPCOMING_NO_EVENT_TEXT');
return;
}
require JModuleHelper::getLayoutPath('mod_dpcalendar_upcoming', '_scripts');
?>
<div class="mod-dpcalendar-upcoming mod-dpcalendar-upcoming-simple mod-dpcalendar-upcoming-<?php echo $module->id; ?>">
<?php foreach ($groupedEvents as $groupHeading => $events) { ?>
<?php if ($groupHeading) { ?>
<div class="mod-dpcalendar-upcoming-simple__group">
<p class="mod-dpcalendar-upcoming-simple__heading dp-group-heading"><?php echo $groupHeading; ?></p>
<?php } ?>
<?php foreach ($events as $index => $event) { ?>
<?php $startDate = $dateHelper->getDate($event->start_date, $event->all_day); ?>
<div class="mod-dpcalendar-upcoming-simple__event">
<div class="row">
<div class="mod-dpcalendar-upcoming-simple__date col-md-4 event-num">
<?php echo $dateHelper->getDateStringFromEvent($event, $params->get('date_format'), $params->get('time_format')); ?>
</div>
<div class="mod-dpcalendar-upcoming-simple__information col-md-8">
<a href="<?php echo $event->realUrl; ?>" class="dp-event-url dp-link"><?php echo $event->title; ?></a>
<p><a href="<?php echo $event->realUrl; ?>" class="dp-event-url dp-link more">More Info >></a>
<a href="<?php echo $event->realUrl; ?>" class="dp-event-url dp-link register-dp">Register >></a></p>
<?php if ($params->get('show_location') && isset($event->locations) && $event->locations) { ?>
<?php foreach ($event->locations as $location) { ?>
<span class="mod-dpcalendar-upcoming-simple__location"
data-latitude="<?php echo $location->latitude; ?>"
data-longitude="<?php echo $location->longitude; ?>"
data-title="<?php echo $location->title; ?>">
<a href="<?php echo $router->getLocationRoute($location); ?>" class="dp-link">
<?php echo $location->title; ?>
</a>
</span>
<?php } ?>
<?php } ?>
</div>
</div> <!-- End of event row -->
<?php if ($event->images->image_intro) { ?>
<div class="mod-dpcalendar-upcoming-simple__image">test
<figure class="dp-figure">
<img class="dp-image" src="<?php echo $event->images->image_intro; ?>"
alt="<?php echo $event->images->image_intro_alt; ?>">
<?php if ($event->images->image_intro_caption) { ?>
<figcaption class="dp-figure__caption"><?php echo $event->images->image_intro_caption; ?></figcaption>
<?php } ?>
</figure>
</div>
<?php } ?>
<?php if ($params->get('show_booking', 1) && \DPCalendar\Helper\Booking::openForBooking($event)) { ?>
<a href="<?php echo $router->getBookingFormRouteFromEvent($event, $return); ?>" class="dp-link dp-link_cta dp-button">
<?php echo $layoutHelper->renderLayout('block.icon', ['icon' => \DPCalendar\HTML\Block\Icon::PLUS]); ?>
<?php echo $translator->translate('MOD_DPCALENDAR_UPCOMING_BOOK'); ?>
</a>
<?php } ?>
<div class="mod-dpcalendar-upcoming-simple__description">
<?php echo $event->truncatedDescription; ?>
</div>
<?php $displayData['event'] = $event; ?>
<?php echo $layoutHelper->renderLayout('schema.event', $displayData); ?>
</div>
<?php } ?>
<?php if ($groupHeading) { ?>
</div>
<?php } ?>
<?php } ?>
</div>
I've had a look at the render.php file for the custom fields but am struggling to understand which code I need to copy into the override file. The render.php is below:
<?php
/**
* @package DPCalendar
* @author Digital Peak http://www.digital-peak.com
* @copyright Copyright (C) 2007 - 2019 Digital Peak. All rights reserved.
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
if (!key_exists('item', $displayData) || !key_exists('context', $displayData)) {
return;
}
$item = $displayData['item'];
if (!$item) {
return;
}
$context = $displayData['context'];
if (!$context) {
return;
}
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$parts = explode('.', $context);
$component = $parts[0];
$fields = array();
if (key_exists('fields', $displayData)) {
$fields = $displayData['fields'];
} else {
if (!empty($item->jcfields)) {
$fields = $item->jcfields;
}
if (!$fields) {
$fields = FieldsHelper::getFields($context, $item, true);
}
}
if (!$fields) {
return;
}
?>
<div class="dp-fields">
<?php foreach ($fields as $field) { ?>
<?php if (!isset($field->value) || $field->value == '') { ?>
<?php continue; ?>
<?php } ?>
<dl class="dp-description dp-field-<?php echo $field->name; ?> <?php echo $field->params->get('render_class'); ?>">
<dt class="dp-description__label"><?php echo $field->params->get('showlabel', 1) ? JText::_($field->label) : ''; ?></dt>
<dd class="dp-description__description"><?php echo $field->value; ?></dd>
</dl>
<?php } ?>
</div>
Could anybody maybe point me in the right direction with this?
Regards
D