Template overrides are a mighty tool for site integrators as they do allow you to adjust the markup of the views. This happens by copying the original files from the component, module or plugin to the templates html folder. It is a well known feature of Joomla and DPCalendar does 100% support it. So all views, modules and plugins are overridable within DPCalendar.
Joomla has covered that topic extensively in their docs:
There are also good tutorials available in the internet, so there is no point for us to copy them here again.
The only thing we want to spread is that you should use overrides only when really needed. The problems are updates, as the override can become incompatible with the changes in the update, especially for new major versions. Please read this post about that topic in our blog. Most changes can be achieved by CSS in your templates custom.css file.
Every view or module has a default.php file. This file is the entrance to the view and calls sublayouts which do render then different blocks. A sublayout has as prefix the name of the main layout, for example default_xxx.php. These sublayouts are often small and have one job to do, so we are isolating the logic. This methodology allows you to override only these sublayouts of the views while leaving the rest intact. Especially the default.php file should NOT be overridden, because when we add new features, we add them mostly in a new sublayout which gets called from the default.php file.
Lets take an example. The calendar view on /components/com_dpcalendar/views/calendar/tmpl has the following files:
For example this is the slimmed down content of the calendar view default.php:
<div class="com-dpcalendar-calendar"> <?php echo $this->loadTemplate('heading'); ?> <?php echo $this->loadTemplate('list'); ?> <?php echo $this->loadTemplate('calendar'); ?> <?php echo $this->loadTemplate('map'); ?> <?php echo $this->loadTemplate('quickadd'); ?> </div>
Every sublayout is called in the default.php through the loadTemplate function. So if you want to change the heading you don't need to make an override of all files, you can just do it with the file default_heading.php.
Comments (0)