dpyic24480 2016-09-08 18:30
浏览 47

Prestashop自定义模块友好网址

I developed a custom module for Prestashop, and I have some issues regarding the friendly url parameters retrieval. If I disable the friendly url, everything works as supposed, but whenever I try with friendly url it doesn't work

So, the problem is the following:. I have a friendly url link just like the one below:

domain.com/22-flower-delivery-Hong+Kong.html

and the other link:

domain.com/22-flower-delivery-Hong+Kong-Sai+Kung.html

The first link gets a country page and the other one is showing a city inside that country.

The route in Prestashop is done like below:

$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' => '[\w]+', 'param' => 'country'),
        'city' => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*', 'param' => 'city'),
        'module_action' => array('regexp' => '[\w]+', 'param' => 'module_action')
    ),
    'params' => array(
        'fc' => 'module',
        'module' => 'vpages'
    )
    )
);

The main issue is that this works if the country or the city has a single word as name, but if there are 2 words (Hong Kong, New Zeeland, etc) then it will crash. A am using urlencode() and decode just to be sure that everything is passed ok but still with no luck.

Could someone help sort it out?

  • 写回答

0条回答 默认 最新

    报告相同问题?