Jump to content

How to add parent CMS category friendly url with the CMS page url?


Recommended Posts



I'm new to Prestashop. I'm trying to create a page url


The CMS Category has the url structure as


The CMS Page has the url structure as


Is there any way to add parent CMS category friendly url with the 

CMS page url?

How can i remove the id's from the category and page?


Kindly guide to do this.








Link to comment
Share on other sites

  • 10 months later...

It's not possible by default, unfortunately. There is no such variable available in the config


Sorry if I introduce myself in this discussion..


Hi Nemo, is there a way to have the CMS category parent in the CMS page Friendly URL overriding Links and Dispatcher in 1.6??


I tried to override the Dispatcher.php editing this  default route:

        'cms_rule' => array(
            'controller' =>    'cms',
            'rule' =>        'content/{category:/}{id}-{rewrite}',
            'keywords' => array(
                'id' =>            array('regexp' => '[0-9]+', 'param' => 'id_cms'),
                'rewrite' =>        array('regexp' => '[_a-zA-Z0-9\pL\pS-]*'),
                'meta_keywords' =>    array('regexp' => '[_a-zA-Z0-9-\pL]*'),
                'meta_title' =>        array('regexp' => '[_a-zA-Z0-9-\pL]*'),

and overriding the function getCMSlink() in Link.php (I did the same for product Categories, adding a rule for list of Categories on categories url and it worked)

    public function getCMSLink($cms, $alias = null, $ssl = null, $id_lang = null, $id_shop = null, $relative_protocol = false)
        if (!$id_lang) {
            $id_lang = Context::getContext()->language->id;
        $url = $this->getBaseLink($id_shop, $ssl, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);
        $dispatcher = Dispatcher::getInstance();
        if (!is_object($cms)) {
            if ($alias !== null && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_title', $id_shop)) {
                return $url.$dispatcher->createUrl('cms_rule', $id_lang, array('id' => (int)$cms, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
            $cms = new CMS($cms, $id_lang);
        $category= new CMSCategory(1, $cms->id_cms_category);

        $params = array();
        $params['id'] = $cms->id;

        $params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias;
        $params['meta_keywords'] = '';
        if(isset($category->link_rewrite) && is_array($category->link_rewrite))
            $params['category'] = implode('/', $category->link_rewrite);
        elseif(isset($category->link_rewrite) && is_string($category->link_rewrite))
            $params['category'] = $category->link_rewrite;
        if (isset($cms->meta_keywords) && !empty($cms->meta_keywords)) {
            $params['meta_keywords'] = is_array($cms->meta_keywords) ?  Tools::str2url($cms->meta_keywords[(int)$id_lang]) :  Tools::str2url($cms->meta_keywords);
        $params['meta_title'] = '';
        if (isset($cms->meta_title) && !empty($cms->meta_title)) {
            $params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title);

        return $url.$dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow, '', $id_shop);

but now I cannot either find the correct URL for the Test CMS page I created.


What am I doing wrong?

thank you,


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...