Jump to content

CMS category name displayed in URL


Recommended Posts

Hello there,
I would like to display my CMS category or sub-category name into my URL. 
The goal is to have this kind of URL :
 
www.mydomain.com/CATEGORY-NAME/page-url.html
- or
www.mydomain.com/SUBCATEGORY-NAME/page-url.html

 

Is somebody know the name of the parameter to put into the SEO parameter ? Or any way to achieved that ?
See the image attached for more informations.
Thanks to all by advance.

 
js

 

PRESTASHOP 1.6

post-936491-0-91949200-1424087198_thumb.jpg

Edited by jsblouet (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

I think it is linked with

root folder  classes/link.php

 

/**
* Create a link to a CMS category
*
* @param mixed $category CMSCategory object (can be an ID category, but deprecated)
* @param string $alias
* @param int $id_lang
* @return string
*/
public function getCMSCategoryLink($cms_category, $alias = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
 
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
 
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms_category))
{
if ($alias !== null && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, array('id' => (int)$cms_category, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$cms_category = new CMSCategory($cms_category, $id_lang);
}
 
// Set available keywords
$params = array();
$params['id'] = $cms_category->id;
$params['rewrite'] = (!$alias) ? $cms_category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($cms_category->meta_keywords);
$params['meta_title'] = Tools::str2url($cms_category->meta_title);
 
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, $params, $this->allow, '', $id_shop);
 
 
 
 
 
 
}
 
/**
* Create a link to a CMS page
*
* @param mixed $cms CMS object (can be an ID CMS, but deprecated)
* @param string $alias
* @param bool $ssl
* @param int $id_lang
* @return string
*/
public function getCMSLink($cms, $alias = null, $ssl = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
 
$url = $this->getBaseLink($id_shop, $ssl).$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);
}
 
// Set available keywords
$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($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);
}
 
we will need to change statements and to define parameters for category or subcategory titles to be apear in urls
Link to comment
Share on other sites

  • 1 year later...

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