I want to create a simple Hello extension to display Hello in OC4.0.2.3, but it returns a message The page you requested cannot be found!
Please tell me why or is there any similar example?
http://localhost/oc4023/index.php?route ... mext/hello
***
My extension/mext folder has a controller folder and view folder as follows:
My Controller: catalog/controller/hello.php
<?php
namespace Opencart\Catalog\Controller\Extension\Mext;
/**
* Class Hello
*
* @package
*/
class Hello extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
$data['text_title'] = "Title";
$data['text_hello'] = "Hello";
return $this->load->view('extension/mext/hello', $data);
}
}
My View: category/view/hello.twig
<div class="card">
<div class="card-header">{{ text_title }}</div>
<p style="text-align: center;">{{ text_hello }}</p>
</div>
Content of install.json file:
{
"name": "hello",
"version": "1.0.0",
"author": "MPN",
"link": "http://localhost"
}
The extension route cannot be used from the URL on the catalog-end side.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Check Controller Namespace: In the console file, the namespace must match the folder structure. Change namespace Opencart\Catalog\Controller\Extension\Mext; to the Controller\Extension\Mext; namespace.
Controller Class Name: Make sure your console class name matches the file name. In this case it must be the ControllerExtensionMextHello class.
View Folder Structure: The folder view structure must match your console namespace. In your case, the view file should be located in catalog/view/extension/mext/hello.twig.
Access URL: Make sure you are accessing the correct URL to view your Hello extension. It should be something like https://ncedcloudam.com http://localhost/oc4023/index.php?route ... mext/hello.
Check Twig File: Make sure your twig file has the correct structure and content
Hope this will help you
Controller Class Name: Make sure your console class name matches the file name. In this case it must be the ControllerExtensionMextHello class.
View Folder Structure: The folder view structure must match your console namespace. In your case, the view file should be located in catalog/view/extension/mext/hello.twig.
Access URL: Make sure you are accessing the correct URL to view your Hello extension. It should be something like https://ncedcloudam.com http://localhost/oc4023/index.php?route ... mext/hello.
Check Twig File: Make sure your twig file has the correct structure and content
Hope this will help you
Who is online
Users browsing this forum: No registered users and 7 guests