Show event location in the Upcoming Events module

RSEvents!Pro's Upcoming events module does not offer, by default, the possibility to display the event's location, only its name. This can, however, be implemented using a combination of custom scripting and template overrides (as can be seen in the image to the right).

Template overrides

Joomla! allows adjusting any component's or module's view for each template that you are using on your website, without risking the loss of the modifications when updating the extension. This is done by copying the view file in the template's html folder and modifying it there.

The complete process of performing template overrides for RSEvents!Pro (including the Upcoming events module) is explained in detail in the article linked below, please refer to it:

Adjust RSEvents!Pro's look, feel and functionality using template overrides
 
The custom code

If you have followed the steps provided in the linked article, you should now have the module's default.php file copied under the following path:

/templates/template_name/html/mod_rseventspro_upcoming/

Edit the file, look for the following code:

 
  <li>
    <a <?php echo $open; ?> href="<?php echo rseventsproHelper::route('index.php?option=com_rseventspro&layout=show&id='.rseventsproHelper::sef($event->id,$event->name),true,$itemid); ?>"><?php echo $event->name; ?></a> <small>(<?php echo $event->allday ? rseventsproHelper::date($event->start,rseventsproHelper::getConfig('global_date'),true) : rseventsproHelper::date($event->start,null,true); ?>)</small>
  </li>
 

and replace it with this one:

 
  <li>
    <a <?php echo $open; ?> href="<?php echo rseventsproHelper::route('index.php?option=com_rseventspro&layout=show&id='.rseventsproHelper::sef($event->id,$event->name),true,$itemid); ?>"><?php echo $event->name; ?></a> <small>(<?php echo $event->allday ? rseventsproHelper::date($event->start,rseventsproHelper::getConfig('global_date'),true) : rseventsproHelper::date($event->start,null,true); ?>)</small>
    <p></p>
    <p><a href="<?php echo($event->locationlink);?>" target="_blank"><?php echo($event->location);?></a></p>
  </li>
 
The code explained

Having a closer look at the code in the module's default.php file, you will notice the $event variable (it is an object, to be more precise). All of the information regarding the event is being stored inside it. To list that information, simply use PHP's print_r() and die() functions, as follows:

<?php print_r($event);die();?>

When refreshing the page in the frontend, it will look something like this:

In the image above, we've highlighted the keys and underlined the values that we have later used in the custom code to return the location's name and link:

 
$event->location
$event->locationlink
 

Tip: Note that there are many more keys with associated values. All that information can be displayed in a similar manner.


One person found this article helpful.


Was this article helpful?

Yes No
Sorry about that