- Posted: July 15, 2008
Creating a template override can be very simple or highly complex. It will depend on the Joomla core generation code you want to override and what you want to do. A relatively simple example that has been requested often in 4Web's work removes those pesky row numbers in the weblinks listing.
Normally, the listing of weblinks within a category will display something like this:
|1|| Joomla! |
Home of Joomla!
Most of the elements in this display can be shown or hidden. The exception is the '#' column. First we identify the generation code.
Weblinks is a component and (if you don't have SEF turned on) you will see a couple URL parameters that will help us locate the code:
option tells us the component's name - com_weblinks. Look in Joomla's components directory and you will see the com_weblinks directory.
view tells us that this is the category view. Look in com_weblinks and you will see views/category/tmpl. This is where the HTML generation code lives.
Two templates do all the work. default.php draws whole the content area and default_items.php draws the individual rows in the table. That's the one we're interested in.
In general, we want to avoid changes to core code whenever possible. For one thing, it might get overwritten on the next Joomla upgrade. So Joomla allows us to copy default_items.php and make it an integral part of our template.
Each template has its own directory under templates. Override code will go into a html directory. In our example, we are overriding a template from com_weblinks category view. So we need to create a directory html/com_weblinks/category. Copy the default_items.php from above into this folder and make your changes here.
What you will find in these template files is a mixture of HTML and php code. If you are not familiar with php, you might want to take a little time getting familiar with the basics. In this case, you can pretty much ignore all the php code since all you want to do is remove the first column in that table.
This has all been a long way of saying copy this file:
to this file:
And make whatever changes you need in the copy.