Prestashop 1.7钩子模块自定义模块中的OUTS

Prestashop 1.7钩子模块自定义模块中的OUTS,prestashop,prestashop-1.7,Prestashop,Prestashop 1.7,当我想使用一些自定义URL时,我很难理解应用于自定义模块的逻辑中的错误 因此,我在自定义模块“页面”中使用hookModuleRoutes,如下所示: public function hookModuleRoutes($params){ $my_link = array( 'module-vpages-dpage' => array( 'controller' => 'dpage', 'rule' =&g

当我想使用一些自定义URL时,我很难理解应用于自定义模块的逻辑中的错误

因此,我在自定义模块“页面”中使用hookModuleRoutes,如下所示:

    public function hookModuleRoutes($params){
    $my_link = array(
        'module-vpages-dpage' => array(
            'controller' => 'dpage',
            'rule' => '{id_country:-}flower-delivery{-:country}{-:city}.html',
            'keywords' => array(
                'id_country' => array('regexp' => '[0-9]+', 'param' => 'id_country'),
                'setCountry' => array('regexp' => '[0-9]+', 'param' => 'setCountry'),
                'country' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'country'),
                'city' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'city'),
                'module_action' => array('regexp' => '[\w]+', 'param' => 'module_action')
            ),
            'params' => array(
                'fc' => 'module',
                'module' => 'vpages',
            )
        )
    );
    return $my_link;
}
以及应该工作的模块控制器:

    class vpagesdpageModuleFrontController extends ModuleFrontController
{
    public $errors = array();
    public $display_column_left = false;
    public $display_column_right = false;
    public $ssl = true;
    public $php_self = 'dpage'; 

        
    public function __construct()
    {
        parent::__construct();
        $this->page_name = 'dpage';
        $this->context = Context::getContext();
    }

    public function initContent()
    {
        parent::initContent();

        $this->context->cookie->__set('productbycountry_id',Tools::getValue('id_country')); 
        $sql     = "SELECT DISTINCT ps_country_lang.id_country, ps_country_lang.name as country, city FROM ps_cms_target_world
                    LEFT JOIN ps_country_lang ON ps_cms_target_world.id_country = ps_country_lang.id_country
                    WHERE ps_country_lang.id_country=" . Tools::getValue('id_country') . "
                    ORDER BY country ASC";
        //die($sql);
        $cPages  = Db::getInstance()->ExecuteS($sql);                
        
        $get_url  = Db::getInstance()->ExecuteS('SELECT domain,physical_uri FROM '._DB_PREFIX_.'shop_url ');
        $protocol = (isset($_SERVER['HTTPS']) ? "https" : "http") ;
        $site_url = "$protocol://".$get_url[0]['domain'].$get_url[0]['physical_uri']."modules";

        $controller_url = $this->context->link->getModuleLink('vpages', 'vPagesController', array(), true);
        $this->context->smarty->assign(array(
            'link' => $this->context->link,
            'controller_url' => $controller_url,
            'cPages' => $cPages,
            'SITEURL' => $site_url
        ));
        
        $country = urldecode(Tools::getValue('country'));        
        $city = urldecode(Tools::getValue('city'));
        if(isset($city) && !empty($city)) $title = " - " . $city; 
        
        $this->context->smarty->assign('meta_title', 'Flower delivery to ' . $country . $title);
       
        //$this->setTemplate('dPage.tpl'); 
        $this->setTemplate('module:vpages/views/templates/front/dPage.tpl');
    }


}
URL是正确创建的,但当我试图访问该页面的内容时,我将在404错误页面中结束 我做错什么了吗? 我想我错过了一些很明显的东西,但我不明白是什么

我已经做了研究,但仍然无法找到解决问题的方法。。 似乎$route['controller']是“产品”,而不是自定义模块


谢谢大家!

我认为您必须在参数中添加“控制器”:

'params' => [
                'fc' => 'module',
                'module' => 'vpages',
                'controller' => 'dpage',
            ]

你的frontController文件名是什么?你搜索什么url?用于访问自定义url的前控制器的url?目标url如下:mysite.com/en/40-flower-delivery-andror.html或en/40-flower delivery-andror-andror+la+Vella.html,具体取决于参数hookmoduleroutes应处理的自定义url,但尚未准备就绪,它也不起作用。你的目标URL是什么?目标URL如下:mysite.com/en/40-flower-delivery-andror.html或en/40-flower delivery-andror+la+Vella.html,具体取决于参数