我的prestashop遇到了问题,我想在模块中创建一个没有使用CMS的网页。

但是当我想通过使用此URL访问控制器时: http://example.com/ prestature / 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
.

我的控制器看起来像这个

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。由于您正在扩展模块,而不是完全脱模的新控制器。

下一件事是你的班级是错误的。它应该是类似的东西。

yourmodulenameyourcontrollernamemodulefrontcontroller

yourmodulename=模块的名称

yourcontrollername=控制器的名称,应位于您的odule /控制器/正面

和最后但并非至少这是完全错误的

$this->setTemplate(__FILE__.'/../../../views/templates/front/ProductList.tpl');
.

你应该使用这个

$this->setTemplate('ProductList.tpl');
.

那种方式,您的文件将位于您的odule /视图/模板/前部

如果您已经遵循所有这些指南,则应能够为首选项中的ModuelController设置友好的URL - > SEO和URL

br's

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top