[*] FO: You can now choose the anchor separator for attributes

This commit is contained in:
Rémi Gaillard
2013-10-09 11:01:18 +02:00
parent 623b8c7960
commit 3b677092bf
10 changed files with 40 additions and 21 deletions
+10 -10
View File
@@ -419,7 +419,7 @@ class BlockLayered extends Module
foreach ($attribute as $param)
{
$selected_filters = array();
$link = '/'.str_replace('-', '_', Tools::link_rewrite($param['name'])).'-'.str_replace('-', '_', Tools::link_rewrite($param['value']));
$link = '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($param['name'])).Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($param['value']));
$selected_filters[$param['type']] = array();
if (!isset($param['id_id_value']))
$param['id_id_value'] = $param['id_value'];
@@ -2103,7 +2103,7 @@ class BlockLayered extends Module
{
foreach ($url_attributes as $url_attribute)
{
$url_parameters = explode('-', $url_attribute);
$url_parameters = explode(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), $url_attribute);
$attribute_name = array_shift($url_parameters);
if ($attribute_name == 'page')
$this->page = (int)$url_parameters[0];
@@ -2113,7 +2113,7 @@ class BlockLayered extends Module
{
foreach ($url_parameters as $url_parameter)
{
$data = Db::getInstance()->getValue('SELECT data FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `url_key` = \''.md5('/'.$attribute_name.'-'.$url_parameter).'\'');
$data = Db::getInstance()->getValue('SELECT data FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `url_key` = \''.md5('/'.$attribute_name.Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').$url_parameter).'\'');
if ($data)
foreach (Tools::unSerialize($data) as $key_params => $params)
{
@@ -3029,7 +3029,7 @@ class BlockLayered extends Module
{
$value_name = !empty($value['url_name']) ? $value['url_name'] : $value['name'];
$value_meta = !empty($value['meta_title']) ? $value['meta_title'] : $value['name'];
$param_group_selected .= '-'.str_replace('-', '_', Tools::link_rewrite($value_name));
$param_group_selected .= Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name));
$param_group_selected_array[Tools::link_rewrite($filter_name)][] = Tools::link_rewrite($value_name);
if (!isset($title_values[$filter_name]))
@@ -3044,12 +3044,12 @@ class BlockLayered extends Module
}
if (!empty($param_group_selected))
{
$param_selected .= '/'.str_replace('-', '_', Tools::link_rewrite($filter_name)).$param_group_selected;
$param_selected .= '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($filter_name)).$param_group_selected;
$option_checked_array[Tools::link_rewrite($filter_name)] = $param_group_selected;
}
// select only attribute and group attribute to display an unique product combination link
if (!empty($param_group_selected) && $type_filter['type'] == 'id_attribute_group')
$param_product_url .= '/'.str_replace('-', '_', Tools::link_rewrite($filter_name)).$param_group_selected;
$param_product_url .= '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($filter_name)).$param_group_selected;
}
@@ -3089,23 +3089,23 @@ class BlockLayered extends Module
// Update parameter filter checked before
if (array_key_exists(Tools::link_rewrite($filter_name), $option_checked_array))
{
$option_checked_clone_array[Tools::link_rewrite($filter_name)] = $option_checked_clone_array[Tools::link_rewrite($filter_name)].'-'.str_replace('-', '_', Tools::link_rewrite($value_name));
$option_checked_clone_array[Tools::link_rewrite($filter_name)] = $option_checked_clone_array[Tools::link_rewrite($filter_name)].Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name));
$nofollow = true;
}
else
$option_checked_clone_array[Tools::link_rewrite($filter_name)] = '-'.str_replace('-', '_', Tools::link_rewrite($value_name));
$option_checked_clone_array[Tools::link_rewrite($filter_name)] = Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name));
}
else
{
// Remove selected parameters
$option_checked_clone_array[Tools::link_rewrite($filter_name)] = str_replace('-'.str_replace('-', '_', Tools::link_rewrite($value_name)), '', $option_checked_clone_array[Tools::link_rewrite($filter_name)]);
$option_checked_clone_array[Tools::link_rewrite($filter_name)] = str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR').str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::link_rewrite($value_name)), '', $option_checked_clone_array[Tools::link_rewrite($filter_name)]);
if (empty($option_checked_clone_array[Tools::link_rewrite($filter_name)]))
unset($option_checked_clone_array[Tools::link_rewrite($filter_name)]);
}
$parameters = '';
ksort($option_checked_clone_array); // Order parameters
foreach ($option_checked_clone_array as $key_group => $value_group)
$parameters .= '/'.str_replace('-', '_', $key_group).$value_group;
$parameters .= '/'.str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', $key_group).$value_group;
// Check if there is an non indexable attribute or feature in the url
foreach ($non_indexable as $value)