rosuandreimihai Posted July 27, 2016 Share Posted July 27, 2016 (edited) Hi all, I am currently developing a custom module. What I want is to have a nice URL, because right now it looks like this: domain.com/flower-deliveries?city=Hamburg&id_country=1&country=Germany I already added a new page to link to the custom module, the page name is flower-deliveries, but still I have the parameters that I have to "hide". Instead, of that link above I would like a URL like this: domain.com/flower-deliveries-Hamburg-Germany.html Can it be done? If yes, how? I've tried with .htaccess, like this. but with no luck.. RewriteRule ^flower-deliveries-([^-]*)-([^-]*)-([^-]*)\.html$ /flower-deliveries?city=$1&id_country=$2&country=$3 [L] Edited July 27, 2016 by rosuandreimihai (see edit history) Link to comment Share on other sites More sharing options...
Krystian Podemski Posted July 27, 2016 Share Posted July 27, 2016 It is not how it should be done, take a look at a moduleRoutes hook in Dispatcher.php Link to comment Share on other sites More sharing options...
rosuandreimihai Posted August 18, 2016 Author Share Posted August 18, 2016 Hi again, I tried 2 methods, but none of them worked.. The first one, was to add a hookModuleRoutes in my controller, just like below: public function hookModuleRoutes($params) { return array( 'module-vpages-dpage' => array( 'controller' => 'dpage', 'rule' => 'flower-deliveries{/:id_country}{/:country}{/:city}', 'keywords' => array( 'id_country' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'id_country'), 'city' => array('regexp' => '[\w]+', 'param' => 'city'), 'country' => array('regexp' => '[\w]+', 'param' => 'country') ), 'params' => array( 'fc' => 'module', 'module' => 'vpages', 'controller' => 'dpage' ) ) ); } And then, in the controllers install: $this->registerHook('moduleRoutes'); That didn't worked, so I tried to override the Dispatcher class, by adding a custom module route: 'module-vpages-dpage' => array( 'controller' => 'dpage', 'rule' => 'flower-deliveries{/:setCountry}{/:id_country}{/:country}{/:city}', 'keywords' => array( 'setCountry' => array('regexp' => '[0-9]+', 'param' => 'setCountry'), 'id_country' => array('regexp' => '[0-9]+', 'param' => 'id_country'), 'city' => array('regexp' => '[\w]+', 'param' => 'city'), 'country' => array('regexp' => '[\w]+', 'param' => 'country'), ), 'params' => array( 'fc' => 'module', 'module' => 'vpages', 'controller' => 'dpage' ) ), When using that custom rule, the link http://europeanflora.com/flower-deliveries?module_action=list&id_country=44&country=Argentina&setCountry=44 was tranformed in http://europeanflora.com/flower-deliveries?module_action=list and it didn't worked and was redirecting me to the first page. Could some one tell me what am I doing wrong? I've spent hours of reading how it should be done and it should be just like the ones above.. Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now