我的 Prestashop 有问题,我想在模块中创建一个网页而不使用 CMS。
但是当我想使用此 Url 访问 Controller 时:http://example.com/comparateur/module/ProduitsMarchand/ProductList
我收到了该消息,当我点击链接时,出现 404 错误
[Debug] This page has moved
Please use the following URL instead: http://example.com/comparateur/index.php?controller=ProductList&module=ProduitsMarchand
我的 Controller 看起来像这样
class ProduitsMarchandProductListModuleFrontController extends ModuleFrontController {
public $php_self ="ProductList";
/**
* Initialize controller
* @see FrontController::init()
*/
public function init() {
parent::init();
}
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent() {
parent::initContent();
$this->setTemplate("ProductList.tpl");
}
}
首选项 > SEO 和 URL
Page: produitsmarchands - productlist
URL: product-list
最佳答案
你犯了一些根本性错误。
首先,您不应该使用 FrontController,而应该使用 ModuleFrontController。由于您正在扩展一个模块,而不是一个完全独立的新 Controller 。
接下来的事情是你的类是错误的。应该是类似这样的东西。
你的模块名称你的 Controller 名称模块前端 Controller
YourModuleName = 您的模块名称
YourControllername = 你的 Controller 的名称,应该位于 yourmodule/controllers/front
最后但并非最不重要的一点是,这是完全错误的
$this->setTemplate(__FILE__.'/../../../views/templates/front/ProductList.tpl');
你应该使用这个
$this->setTemplate('ProductList.tpl');
这样你的文件将位于 yourmodule/views/templates/front
如果您遵循了所有这些准则,您应该能够在“首选项”->“SEO 和 URL”中为 moduelController 设置一个友好的 URL
BR的
关于php - 模块 Controller 重定向到 404 Prestashop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22009125/