Jump to content

Url ภาษาไทย PrestaShop 1.5.4.1 ได้ 100% (ใส่สระได้/สระไม่หาย) ครับ


teerachai
 Share

Recommended Posts

ไฟล์ที่ต้องแก้มีดั้งนี้

 

1.\classes\Tools.php

 

ค้นหา Function str2url แล้ว copy ทับไปเลยครับ

 

public static function str2url($str)
{
 static $allow_accented_chars = null;
 if ($allow_accented_chars === null)
  $allow_accented_chars = Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
 $str = trim($str);
 if (function_exists('mb_strtolower'))
  $str = mb_strtolower($str, 'utf-8');
 elseif (!$allow_accented_chars)
  $str = Tools::replaceAccentedChars($str);
 // Remove all non-whitelist chars.
 if ($allow_accented_chars)
  $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL\pM]/u', '', $str);
 else
  $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str);
 $str = preg_replace('/[\s\'\:\/\[\]-]+/', ' ', $str);
 $str = str_replace(array(' ', '/'), '-', $str);
 // If it was not possible to lowercase the string with mb_strtolower, we do it after the transformations.
 // This way we lose fewer special chars.
 if (!function_exists('mb_strtolower'))
  $str = strtolower($str);
 return $str;
}

 

2.\classes\Validate.php

 

ค้นหา Function isLinkRewrite และ isRoutePattern แล้ว copy ทับไปเลยครับ (อยู่ติดกันครับ)

 

public static function isLinkRewrite($link)
{
 if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
  return preg_match('/^[_a-zA-Z0-9\-\pL\pM]+$/u', $link);
 return preg_match('/^[_a-zA-Z0-9\-]+$/', $link);
}
public static function isRoutePattern($pattern)
{
 if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
  return preg_match('/^[_a-zA-Z0-9\(\)\.{}:\/\-\pL\pM]+$/u', $pattern);
 return preg_match('/^[_a-zA-Z0-9\(\)\.{}:\/\-]+$/', $pattern);
}

 

3. \classes\Dispatcher.php

 

Copy ทับไปเลยครับ

 

public $default_routes = array(
 'category_rule' => array(
  'controller' => 'category',
  'rule' =>  '{id}-{rewrite}',
  'keywords' => array(
'id' =>	array('regexp' => '[0-9]+', 'param' => 'id_category'),
'rewrite' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_title' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
  ),
 ),
 'supplier_rule' => array(
  'controller' => 'supplier',
  'rule' =>  '{id}__{rewrite}',
  'keywords' => array(
'id' =>	array('regexp' => '[0-9]+', 'param' => 'id_supplier'),
'rewrite' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_title' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
  ),
 ),
 'manufacturer_rule' => array(
  'controller' => 'manufacturer',
  'rule' =>  '{id}_{rewrite}',
  'keywords' => array(
'id' =>	array('regexp' => '[0-9]+', 'param' => 'id_manufacturer'),
'rewrite' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_title' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
  ),
 ),
 'cms_rule' => array(
  'controller' => 'cms',
  'rule' =>  'content/{id}-{rewrite}',
  'keywords' => array(
'id' =>	array('regexp' => '[0-9]+', 'param' => 'id_cms'),
'rewrite' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_title' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
  ),
 ),
 'cms_category_rule' => array(
  'controller' => 'cms',
  'rule' =>  'content/category/{id}-{rewrite}',
  'keywords' => array(
'id' =>	array('regexp' => '[0-9]+', 'param' => 'id_cms_category'),
'rewrite' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_title' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
  ),
 ),
 'module' => array(
  'controller' => null,
  'rule' =>  'module/{module}{/:controller}',
  'keywords' => array(
'module' =>   array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'module'),
'controller' =>  array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'controller'),
  ),
  'params' => array(
'fc' => 'module',
  ),
 ),
 'product_rule' => array(
  'controller' => 'product',
  'rule' =>  '{category:/}{id}-{rewrite}{-:ean13}.html',
  'keywords' => array(
'id' =>	array('regexp' => '[0-9]+', 'param' => 'id_product'),
'rewrite' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'ean13' =>   array('regexp' => '[0-9\pL]*'),
'category' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'categories' =>  array('regexp' => '[/_a-zA-Z0-9-\pL\pM]*'),
'reference' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_title' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'manufacturer' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'supplier' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'price' =>   array('regexp' => '[0-9\.,]*'),
'tags' =>   array('regexp' => '[a-zA-Z0-9-\pL]*'),
  ),
 ),
 // Must be after the product and category rules in order to avoid conflict
 'layered_rule' => array(
  'controller' => 'category',
  'rule' =>  '{id}-{rewrite}{/:selected_filters}',
  'keywords' => array(
'id' =>	array('regexp' => '[0-9]+', 'param' => 'id_category'),
/* Selected filters is used by the module blocklayered */
'selected_filters' =>  array('regexp' => '.*', 'param' => 'selected_filters'),
'rewrite' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
'meta_title' =>  array('regexp' => '[_a-zA-Z0-9-\pL\pM]*'),
  ),
 ),

Share this post


Link to post
Share on other sites

ถ้าแก้ไขไฟล์ระบบตรง ๆ ให้ระมัดระวังถ้ามีการอัพรุ่นด้วยโมดูล autoupgrade ด้วยนะครับ มันอาจจะเขียนทับไฟล์ที่เราแก้ไขไปให้ระวังตรงจุดนี้ด้วยนะครับ

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 1 year later...

Thanks for mr. teerachai above post Posted 10 July 2013 - 02:32 PM.

 

i solved on my ps1.5.6.1. www.7zhop.com

 

i also add

Thank you, This has solved the same problem for generating Friendly URL in Thai Language.

 

http://www.prestashop.com/forums/topic/213603-solved-what-is-ps-allow-accented-chars-url-friendly-url/
The SQL code I used is:
INSERT INTO `ps_configuration` (`id_configuration`, `id_shop_group`, `id_shop`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, NULL, NULL, 'PS_ALLOW_ACCENTED_CHARS_URL', '1', '2014-00-00 00:00:00', '2014-00-00 00:00:00');

 

Thanks All

http://www.7zhop.com/th/cosmetic/167-ครีมทาผิวขาวตัว-constanta-whitening-uv-protec-powder-cake.html

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More