HOWTO write a template override

Sometimes, we have to change how things are displayed in our site. Some of us want to show the order summary on the left and the payment options on the right.

Some of us will like to change the layout of the billing / shipping address. And the question is how to do this without editing the core files of K2Store.

Joomla has a built-in solution for this: template overide. In Joomla, the views (or the output we see on the site) are handled separetely. So we can style the output or change the output easily.

This guide will take you step-by-step on writing a template override.

In our case, we take the default cart layout for writing an overide.

The following files control this layout. (Located in /components/com_k2store/views/mycart/tmpl folder)

  1. default.php

Step 1: Create override structure in your template.

We can create template overirides for only those files and folders that reside in the views folder of a component (Example: components/com_k2store/views).

All the template overrides should reside inside the html folder of your template.

Let us say, your template's name is: YOUR_TEMPLATE

And you want to write overide for the files in the mycart view of K2Store component.

Then you should first go to

/templates/YOUR_TEMPLATE/html

And create a folder named: com_k2store

Then go to

/templates/YOUR_TEMPLATE/html/com_k2store

and create folder called: mycart

Step 2: Copying files 

Now

Then you should copy the default.php from

/component/com_k2store/views/mycart/tmpl

to

/templates/YOUR_TEMPLATE/html/com_k2store/mycart

Step 3: Edit the files.

Now you can edit the default.php and carry out any changes. Like altering the scaffolding etc.

 

your_template