How to Make a Theme With OpenCart from Scratch

new_theme

This post would be very interesting sake of creating an own theme on popular e-commerce CMS (Content Management System). Before you make a theme with OpenCart, you should have basic understanding of MVC pattern and structure of OpenCart theme. Covering full part in single article is rather difficult job where by I decided to explain it shortly. I assume that you know basics PHP and HTML perception.

You may also understand basic structure of theme from official default theme. Just open it and browse the directories, get access to theme directory through catalog/view/theme/default

A Quick Explanation to Theme Structure of OpenCart

I believe you working on local environment and not live site. So open htdocs folder and start tweaking now. First of all create a new theme folder in catalog/view/theme, i have named it as mytheme then Create image, JavaScript, template directories inside catalog/view/theme/mytheme directory, these are the base directories for theme files.

opencart-theme-structure

  • Image: It consists of only theme related images, every front-end image files store under this directory. Don’t be confused back-end images stores at /admin/view/image folder
  • Stylesheet: OpenCart uses this directory to store front-end stylesheets. looks like /catalog/view/theme/stylesheet/stylesheet.css
  • Template: not all the template files stored under this, it is container storing theme related files, get access to template folder over /catalog/view/theme/[Theme Name]/template

As mentioned above all template are stores inside /catalog/view/theme/default/template directories with .tpl extension. Opencart uses .tpl extension that means template file. If you missed to build any important directories in custom theme, OpenCart’s fallback system will find for the missed files or directories and if not exists loads it from default theme directory. Once you finished all the steps, eventually one step is remaining create files inside corresponding directories. here i going to cover a small module for creating or customizing theme.

Creating a Custom Page

You will need to create a controller and view file under controller and view folder respectively.

The language file should as follows for corresponding controller file to fetch the from it.

next is the view function it will load according to controller functions

You may also like...

1 Response

Leave a Reply

Your email address will not be published. Required fields are marked *