Jump to content

SEF url module in language selector link


SP Serhii

Recommended Posts

Hello.

I have simple module news. Link to lists posts is /news/ . Link to detail news is /news/post/2-our-best-news . But, in language selector, link well be like this /en/module/extnews/post?id_tab=2&slug=our-best-news

Code from override/modules/extnews/extnews.php :

public function hookModuleRoutes() {
  $main_route = 'news';

  return array(
    'module-extnews-main' => array(
    'controller' => 'main',
    'rule'       => $main_route,
    'keywords'   => array(),
    'params'     => array(
    'fc'     => 'module',
    'module' => 'extnews',
    ),
  ),
  'module-extnews-show' => array(
    'controller' => 'post',
    'rule'       => $main_route . '/post{/:id_tab}-{:slug}',
    'keywords' => array(
    'slug'       =>   array('regexp' => '[_a-zA-Z0-9-\pL]+','param' => 'slug'),
    'id_tab' =>    array('regexp' => '[0-9]+', 'param' => 'id_tab'),
    ),
    'params'     => array(
    'fc'     => 'module',
    'module' => 'extnews',
    ),
    ),
  );
}

I have two controllers: override/modules/extnews/controllers/front/main.php , override/modules/extnews/controllers/front/post.php

What I don next: I added in override override/classes/Dispatcher.php :

$this->default_routes = [
  'module-extnews-main' => array(
      'controller' => 'main',
      'rule'       => 'news',
      'keywords'   => array(),
      'params'     => array(
      'fc'     => 'module',
      'module' => 'extnews',
    ),
  ),
  'module-extnews-post' => array(
      'controller' => 'post',
      'rule'       => 'news/post/{id_tab}-{slug}',
      'keywords' => array(
      'slug'       =>   array('regexp' => '[_a-zA-Z0-9-\pL]+','param' => 'slug'),
      'id_tab' =>    array('regexp' => '[0-9]+', 'param' => 'id_tab'),
    ),
    'params'     => array(
      'fc'     => 'module',
      'module' => 'extnews',
    ),
  ),
  'category_rule' => [
  'controller' => 'category',
  ........

After that, url in language selector becomes /en/news/post/2_ but I need like this /en/news/post/2-our-best-news . What I doing wrong? Please, help.

Link to comment
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...