doushou1298
2014-02-25 08:58
浏览 113
已采纳

模块控制器重定向到404 Prestashop

I have a problem with my Prestashop, i would like to create a webpage in a module without using the CMS.

But when I want to access the controller by using this Url : http://example.com/comparateur/module/ProduitsMarchand/ProductList

I have that message & when i click on the link, i have a 404 error

[Debug] This page has moved
Please use the following URL instead: http://example.com/comparateur/index.php?controller=ProductList&module=ProduitsMarchand

My controller looks like this

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");
    }
}

Preferences > SEO & URLs

Page: produitsmarchands - productlist
URL: product-list

图片转代码服务由CSDN问答提供 功能建议

我的Prestashop有问题,我想在不使用CMS的情况下在模块中创建网页。< / p>

但是当我想使用此Url访问控制器时: http://example.com/comparateur/module/ProduitsMarchand/ProductList

我有这样的信息&amp; 当我点击链接时,我有404错误

  [Debug]此页面已移动
请使用以下网址:http://example.com/comparateur  /index.php?controller=ProductList&module=ProduitsMarchand
nn

我的控制器看起来像这样

 类ProduitsMarchandProductListModuleFrontController 扩展ModuleFrontController {
 
 public $ php_self =“ProductList”; 
 / ** 
 *初始化控制器
 * @see FrontController :: init()
 * / 
 n公共函数init(){
  parent :: init(); 
} 
 
 / ** 
 *分配与页面内容相关的模板变量
 * @see FrontController :: initContent()
 * / 
 n公共函数initContent(){  
 parent :: initContent(); 
 
 $ this-&gt; setTemplate(“ProductList.tpl”); 
} 
} 
   
 
 

偏好&gt; SEO&amp; 网址

 页面:produitsmarchands  -  productlist 
URL:product-list 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqo58772 2014-02-25 12:13
    已采纳

    You got a few fundamental mistakes.

    First of all you should'nt be using FrontController but rather ModuleFrontController. Since you are extending a module not a fully sepearate new controller.

    Next thing is that your class is wrong. It should be something similar to this.

    YourModuleNameYourControllerNameModuleFrontcontroller

    YourModuleName = name of your module

    YourControllername = name of your controller and should be located in yourmodule/controllers/front

    And last but not least this is completely wrong

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

    You should use this

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

    That way your file will be located in yourmodule/views/templates/front

    And if you have followed all of those guidelines you should be able to set a friendly url for your moduelController in Preferences -> SEO & URL

    BR's

    打赏 评论

相关推荐 更多相似问题