Home / Theme Collections / If you encounter a conflict between PrettyURLs and Leo Blog related to the file:

If you encounter a conflict between PrettyURLs and Leo Blog related to the file:

If you encounter a conflict between PrettyURLs and Leo Blog related to the file:

/override/classes/Dispatcher.php

please follow the steps below carefully.


🧰 Step-by-Step Solution

  1. Go to: /modules/prettyurls/override/classes/
  2. Copy the file Dispatcher.php manually into your PrestaShop override folder: /override/classes/Dispatcher.php
  3. Open this file with any text editor.
  4. Inside the function public function getController($id_shop = null) find the line: if (preg_match('/blog/', $this->request_uri)) {
  5. Just before the line: if ($module_exists == true) { insert the following block of code 👇

💻 Code to Insert

$module_exists_lblog = Module::isEnabled('leoblog');
if ($module_exists_lblog == true) {
    // Load custom routes from modules
    $modules_routes = Hook::exec('moduleRoutes', ['id_shop' => $id_shop], null, true, false);
    if (is_array($modules_routes) && count($modules_routes)) {
        foreach ($modules_routes as $module_route) {
            if (is_array($module_route) && count($module_route)) {
                foreach ($module_route as $route => $route_details) {
                    if (array_key_exists('controller', $route_details)
                        && array_key_exists('rule', $route_details)
                        && array_key_exists('keywords', $route_details)
                        && array_key_exists('params', $route_details)
                    ) {
                        if (!isset($this->default_routes[$route])) {
                            $this->default_routes[$route] = [];
                        }
                        $this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
                    }
                }
            }
        }
    }

    $language_ids = Language::getIDs();
    if (isset($context->language) && !in_array($context->language->id, $language_ids)) {
        $language_ids[] = (int) $context->language->id;
    }

    include_once(_PS_MODULE_DIR_.'leoblog/loader.php');
    $config = LeoBlogConfig::getInstance();

    // Leo Blog default routes
    if (!isset($this->default_routes['module-leoblog-list'])) {
        $this->default_routes['module-leoblog-list'] = [
            'controller' => 'list',
            'rule' => _LEO_BLOG_REWRITE_ROUTE_.'.html',
            'keywords' => [],
            'params' => ['fc' => 'module', 'module' => 'leoblog']
        ];
    }

    if ($config->get('url_use_id', 1) && (!Tools::getIsset('configure') || Tools::getValue('configure') != 'gsitemap')) {
        // URLs with IDs
        if (!isset($this->default_routes['module-leoblog-blog'])) {
            $this->default_routes['module-leoblog-blog'] = [
                'controller' => 'blog',
                'rule' => _LEO_BLOG_REWRITE_ROUTE_.'/{rewrite}-b{id}.html',
                'keywords' => [
                    'id' => ['regexp' => '[0-9]+', 'param' => 'id'],
                    'rewrite' => ['regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'rewrite'],
                ],
                'params' => ['fc' => 'module', 'module' => 'leoblog']
            ];
        }

        if (!isset($this->default_routes['module-leoblog-category'])) {
            $this->default_routes['module-leoblog-category'] = [
                'controller' => 'category',
                'rule' => _LEO_BLOG_REWRITE_ROUTE_.'/{rewrite}-c{id}.html',
                'keywords' => [
                    'id' => ['regexp' => '[0-9]+', 'param' => 'id'],
                    'rewrite' => ['regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'rewrite'],
                ],
                'params' => ['fc' => 'module', 'module' => 'leoblog']
            ];
        }
    } else {
        // URLs without IDs
        $category_rewrite = $config->get('category_rewrite_'.Context::getContext()->language->id, 'category');
        $detail_rewrite = $config->get('detail_rewrite_'.Context::getContext()->language->id, 'detail');

        if (!isset($this->default_routes['module-leoblog-blog'])) {
            $this->default_routes['module-leoblog-blog'] = [
                'controller' => 'blog',
                'rule' => _LEO_BLOG_REWRITE_ROUTE_.'/'.$detail_rewrite.'/{rewrite}.html',
                'keywords' => [
                    'id' => ['regexp' => '[0-9]+', 'param' => 'id'],
                    'rewrite' => ['regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'rewrite'],
                ],
                'params' => ['fc' => 'module', 'module' => 'leoblog']
            ];
        }

        if (!isset($this->default_routes['module-leoblog-category'])) {
            $this->default_routes['module-leoblog-category'] = [
                'controller' => 'category',
                'rule' => _LEO_BLOG_REWRITE_ROUTE_.'/'.$category_rewrite.'/{rewrite}.html',
                'keywords' => [
                    'id' => ['regexp' => '[0-9]+', 'param' => 'id'],
                    'rewrite' => ['regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'rewrite'],
                ],
                'params' => ['fc' => 'module', 'module' => 'leoblog']
            ];
        }
    }

    // Register all routes
    foreach ($this->default_routes as $id => $route) {
        $route = $this->computeRoute(
            $route['rule'],
            $route['controller'],
            $route['keywords'],
            isset($route['params']) ? $route['params'] : []
        );
        foreach ($language_ids as $id_lang) {
            $this->routes[$id_shop][$id_lang][$id] = $route;
        }
    }
}


OR simple download this file:
https://drive.google.com/file/d/1kgLIq3MbLNWaiTaARUbwjYN35l1Z-kBR/view

🔧 Final Step

After saving the file:

  1. Clear the cache folder: /var/cache/prod
  2. In your back office, go to Shop Parameters → SEO & URLs
    • Disable “Friendly URL” → Save
    • Enable it again → Save once more

This will rebuild all routes and make both PrettyURLs and Leo Blog work together correctly.


Would you like me to make this instruction formatted for your customer (with code highlighting, download link, and visual separators — like a mini documentation page)?

About Leo Theme

Check Also

Leotheme Black Friday 2022

Prestashop Theme and Module Black Friday and Cyber Monday Sales Leotheme 2022 30% Off

Prestashop Leotheme Black Friday 2022 Promotion! Dear valued customers, Black Friday and Cyber Monday Sales …

Leave a Reply