I want to create a custom page in opencart.
I know I can put a custom page in the information section using the admin area however what I would like is a controller which points to a few other pages.
I dont fully understand how to do this.
In codeigniter you would create a controller and a view and if needed setup some rules in the routes file but I cannot see anything like this.
Would somebody mind explaining or pointing me to some instructions on how to do this please.
Thank you
It’s pretty simple to do to be honest. You need to create a controller for your file, naming based on the folder and filename. For instance
common/home.phphasThis is accessed using
index.php?route=common/homeand accesses theindex()method. If you want to call another method, for instance foo, you would need to define the method asand would call it using index.php?route=common/home/foo
As for rendering the view, that’s a bit trickier. Basically you need to add all of this to the end of your controller method
Which will render
/catalog/view/theme/your-theme-name/template/common/new_template_file.tplIf that file doesn’t exist, it will attempt to use the same path in the
defaulttheme folderI’d recommend you take a look at a few controllers and templates to get your head around where everything comes from properly, but that’s the basic gist of how it works