This is a very simple example. It does not even require any CSS.
Hopefully this exmplains the principle in a practical way
This is in...
modules/mod_menu/tmpl/default.php
It contains a lot of code related to menu item style and depth, we don't need this, as out new menu will be for a fixed purpose
Starting simple, we'll look at a menu module override.
This will be a layout overide for use in the footer of a site.
So, we'll copy the file from...
modules/mod_menu/tmpl/default.php
to...
templates/<template_name>/html/mod_menu/footer.php
Notice we've called it "footer.php" so it wont be the default, and we'll have to select it as an alternate layout.
This new file is in...
templates/<template_name>/html/mod_menu/footer.php
This new file is much simpler.
<boring intro> I'm developer with a design background, developing on Joomla since the Mambo days.
Over the years I've produced a wide range of Joomla sites for financial corporations, football clubs, MPs, non-profits, news outlets, business directories, e-learning, the NHS, hospitality and a range of other clients. I typically work for digital agencies to assist and extend their development teams. My company is call SSOFB.
I live Aberdeen, but grew up in London, and have also lived in Edinburgh, Sydney and Glasgow. </boring intro>
https://twitter.com/AndyGasman
http://www.ssofb.co.uk
This is a practical example, a client wanted a twitter widget on site header that showed the latest tweet. We took the Twitter Extension JMod TweetDisplay, which works with the latest Twitter API
So, we'll copy the file from...
modules/mod_jmod_tweetdisplay/tmpl/default.php
to...
templates/<template_name>/html/mod_jmod_tweetdisplay/header.php
Notice we've called it "header.php" so it wont be the default, and we'll have to select it as an alternate layout.
This is a slightly more involved example, this will require some CSS to go with it.
This new file is in...
templates/<template_name>/html/mod_jmod_tweetdisplay/header.php
This new file is much simpler.
This is in...
modules/mod_jmod_tweetdisplay/tmpl/default.php
It's pretty complicated, as it offers a lot of good options by default. For out single purpose module, we can strip a lot of this out.
This is in...
modules/mod_articles_latest/tmpl/default.php
A good example of this would be blog type content, where you would want an image on each story.
We'll just use the "Full article image", but we could use the "Intro Image" as well or instead.
in...
templates/<template_name>/html/mod_articles_latest/default.php
from...
components/com_content/views/article/tmpl/default.php
to...
templates/<template_name>/html/com_content/article/default.php
We'll make the helper file...
templates/<template_name>/html/image_helper.php
This is a bit un-Joomla! but is a quick solution, and explains how much you can sqeeze into a template override
A practical introduction to Joomla! template overrides.
A way of overriding how a module of component looks.
This is done in the template, so nice is and clean.
It leverages the MVC design patern of Joomla.
It is probably one of those things that is simpler to show what is possible using examples.
We'll start with some simpler ones.
Alternative layouts allow you have variations on a template override.
Just copy the "default.php" file to a new name. These are then picked up in the module or component admin.
There is a gotcha here, if you put underscores in your filename, then it wont show up in the admin screen
When Joomla renders the view, it checks the template for an overide, before rendering the default view.
If it finds a default view in the template, it renders that. If a custom view is specified, it uses that.
You can set up mulitple views per compoent or module
I'd be happy to explain or expand on any of this, catch me after this or any time
https://twitter.com/AndyGasman
http://www.ssofb.co.uk
This is slightly different for modules and components, but works on the same principle.