I'm a developer and I want to create an extension for one of my clients for OpenCart for version 4.0.2.3. This extension will be of type "Theme" and I want it to have the following features:
1. I want to be able to run the files that will be in the extension instead of the ones that will be in the main catalog folder of the main OpenCart structure. I have completed this particular feature by customizing the example theme that OpenCart has preinstalled for us.
2. I want to be able to create a custom folder with a file (eg extension/extension_name/catalog/..../sections/portfolio) inside the extension, which will not exist in the main folder catalog of the main OpenCart structure and when I call from the frontend the page via $_GET (eg index.php?route=section/portfolio), it loads the content directly from the extension.
For the 2nd part, no matter what I've done it doesn't reroute me to the extension for the route parameter and it returns that the page doesn't exist because the file doesn't exist in the main catalog folder of the OpenCart main structure.
Below I present to you the progress of my extension so far which is located in the path extension/extension_name/catalog/controller/startup.
Code: Select all
<?php
namespace Opencart\Catalog\Controller\Extension\ThemeName\Startup;
class Settings extends \Opencart\System\Engine\Controller
{
public function index(): void
{
if ($this->config->get('config_theme') == 'settings' && $this->config->get('theme_ThemeName_status'))
{
// Add event via code instead of DB
// Could also just set view/common/header/before
$this->event->register('view/*/before', new \Opencart\System\Engine\Action('extension/ThemeName/startup/Settings.event'));
}
}
public function event(string &$route, array &$args, mixed &$output): void
{
$override =
[
'common/header',
'common/home',
'common/maintenance',
'section/portfolio'
];
if (in_array($route, $override))
{
$route = 'extension/ThemeName/' . $route;
}
}
}