From version 1.5.2 onwards of JEvents its possible to apply multiple template overrides for the latest events module. This means that you can have one module that displays "Today's Events" and another displaying "This Weeks Events" and have these formatted in completely different ways.
This article describes this process based on a specific example. We want to create a module to show "This Weeks Events" as in the partial screenshot below.
The first thing to do is create a new latest jevents module and set the parameters as in the following screenshot.
The important points to note are
- We have named the "Override Layout" as "latestthisweek". We will create a specific layout to match this name which will then be used by this module.
- We have said to "Use Settings Below"
- We want to force this module to show events for the next 7 days so we selected display mode 2 and specified 7 days for our date range.
You now need to create a special template override file. I am using the Ruthin layout and my template is ja_purity so the file I create is called:
templates/ja_purity/html/mod_jevents_latest/ruthin/latestthisweek.php
If you are using a different template and/or layout then change this file path to match your settings.
The code has a few comments which should make the flow fairly obvious (note that I have included inline styles but you will probably want to put these style settings in your template stylesheet or JEvents style sheet override). For more information about the data fields that are available to you see the bottom of this article.
You can get a copy of the raw code here (and here for Joomla! 1.5).
This is a highlighted version of part of the source:
/**
* copyright (C) 2009 GWE Systems Ltd - All rights reserved
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
// make sure the parent class is included
include_once(JPATH_SITE.'modules/mod_jevents_latest/tmpl/ruthin/latest.php');
class OverrideRuthinModLatestViewLatestthisweek extends RuthinModLatestView
{
}
Data fields
The main data fields available to you (apart from those used in the file are) are
- $row->extra_info()
- $row->contact_info()
- $row->hits()
- $row->created_by()
- $row->is_repeat()
- $row->bgcolor()
- $row->fgcolor()
- $row->catid()
- $row->getCategoryName()
- $row->getCategoryDescription()