The default theme can serve as the base for creating a custom theme, one can build a custom theme in OpenCart in two different ways.
- One can completely replace the front-end files with the new files [OR]
- Change the few things such as layouts color combinations.
Now create a new directory under the
catalog/view/theme and name it as
customtheme. The folder further serve as a location for
images,
stylesheets and
templates of the new theme, next create three more directives under the created new directory and name them as
image,
stylesheet and
template as shown in the image below.
Now just copy few file like
header.tpl and
home.tpl from the template directory of default theme and open the
header.tpl file located under the path
template/common/header.tpl, the code in this file is the main reason for displaying the header part throughout the store site, there are some styleheet references hard coded to default theme so change the reference to the newly created theme directory.
Change the below line in the code as.
[c]<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/stylesheet.css" />[/c]
Replace
[c]<link rel="stylesheet" type="text/css" href="catalog/view/theme/customtheme/stylesheet/stylesheet.css" />[/c]
Now in order to activate the created theme follow the steps below.
Step 1 -
Open the admin dashboard, go to
Extension in the side menu bar. Select the
Themes from the dropdown menu from the Extension List as shown in the image below.
Step 2 -
Now the themes for the store get displayed click on the
Edit button as shown in the image below.
Step 3 -
The page now redirect to another page, now select the built theme using the drop down box under the
Theme Directory and then click the
Save button on the top as shown in the image below.
Step 4 -
Now go to the store home page and check the output, the theme get replaced with the new built theme.