-
Your shopping cart is empty!
In this series, I am going to explain how you will be able to build a custom theme for Opencart In this first part, I'll explain basic structure of the OpenCart theme.
Before continuing more, I assume that you simply have working OpenCart installation on your system. If that's not the case, check the OpenCart tutorial and setup the same. Once you have a working OpenCart site, you are ready to move further.
OpenCart is developed using a framework called MVC which that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application. As a theme developer, you don't need to worry about tweaking the files all the time which contains the application logic and template code together.
OpenCart provides really clean directory structure when it comes to organization of the framework. All the files related to the back-end interface are placed in the admin
directory. Files dealing with front-end interface are placed in the catalog
directory. But what we are really going to look into is the catalog
directory where store front related files are residing.
MVC, is a very popular framework used by developers. In Opencart, the view
part is where we place all the theme related code. If you look at catalog
structure, you can see how OpenCart organiz.
Getting Familiar With the Presentation Layer
All theme related files are stored under theme folder. OpenCart comes with a default theme is available in default
directory. This is the part which we will explore in this section. At the deeper level, there are two more directories: javascript
and theme
.
For now, let's just assume that all of the required JavaScript files are placed in the javascript
directory. Sometimes there is an exception to this in which case we can also place stylesheets and related image files under this directory, as well. For example, OpenCart provides the colorbox library which contains more than just JavaScript.
Structure of Default Theme
For example, if you give a quick look at the account
directory under template you will see most of the files are related to user screens in the front-end.
Let us looks like within the template
directory. Before moving ahead, it's worth noting that although OpenCart comes with a bunch of built-in modules that provide the features required by a basic shopping cart, you can develop your own modules as well for your custom requirements.
With that said, let's have a closer look at the template categorization.
Apart from the template structure explained above, there are still other template directories that contain page-specific template files. In terms of OpenCart, we can say that they are route specific template files.
For example, when you visit the "My Account" page in the front-end, the template associated with that should be found under catalog/view/theme/default/template/account
. Later in the series, we'll see how to find a specific template file looking at the url path of that page.
That's the end of the first part of this series. You should be familiar with the basic theme structure of the OpenCart.
In the next part, we'll learn how to create a custom theme in the OpenCart.