Aliz
Aliz

Reputation: 407

Prestashop: Override URL scheme of Blog module

I bought a Blog module in order to write blog posts directly in Prestashop : https://addons.prestashop.com/fr/blog-forum-actualites/25908-blog.html

But I found out that this module forces me to have 3 components in my blog posts URLs like this: blog/post/post-title

In the module settings I can choose other words for the first two components (e.g. content/article/post-title) but I can't delete one of the components.

I'd like to get rid of one of the components in order to get this scheme: blog/post-title

How can I do this without breaking too much the code of the module?

Upvotes: 0

Views: 573

Answers (1)

Alexander Grosul
Alexander Grosul

Reputation: 1814

If everything is done correctly in the module, you need to edit

public function hookModuleRoutes()
{
}

in the main module file. Edit that router which responsible for the post. It should be something like this:

return array(
    'module-YOURMODULENAME-CONTROLLERNAME' => array(
        'controller' => 'CONTROLLERNAME',
        'rule'       => 'blog/post/{title}',
        'keywords'   => array(
            'title'        => array('regexp' => '[_a-zA-Z0-9\pL\pS-]*')
        ),
        'params'     => array(
            'fc'     => 'module',
            'module' => 'YOURMODULENAME',
        )
    )
);

so you can edit

'rule'       => 'blog/post/{title}'

to

'rule'       => 'blog/{title}'

but be careful and check if no other blog page has the same rule.

Upvotes: 1

Related Questions