Jump to content

Custom Route Module - Dispatcher error


Recommended Posts

Hi there, i'm trying to create a custom route form my module. I'm working on 1.6.


Here is my code

$my_routes = array(
	'module-gfblog-blog' => array(
		'controller' => 'blog',
	        'rule' => 'news{/:module_action}{/:id}',
	        'keywords' => array(
	        		'id' => array('regexp' => '[\d]+', 'param' => 'id'),
	        		'module_action' => array('regexp' => '[\w]+', 'param' => 'module_action')
	        'params' => array(
	            'fc' => 'module',
	            'module' => 'gfblog',
	            'controller' => 'blog',

return $my_routes;

I cannot understand why it is working only when remove id from rule and keywords.

whe i try to access /news/single/7 system warn me like this:

Dispatcher::createUrl() miss required parameter "id" for route "module-gfblog-blog" generated by Dispatcher class

if (!array_key_exists($key, $params))
654. 				throw new PrestaShopException('Dispatcher::createUrl() miss required parameter "'.$key.'" for route "'.$route_id.'"');

Why keyword module_action is working and id not ?


Thank you






Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More