Jump to content

แสดง Friendly URL ไทย 1.5


Suthichai

Recommended Posts

งมมาหลายวัน เพิ่งทำได้ครับ เลยอยากมาบอกเผื่อผู้ที่ต้องการรู้จะได้ไม่ต้องเสียเวลา อันนี้ลองกับ 1.5.0.15

หลังจากแก้เสร็จก็สามารถป้อนไทยและแสดง Friendly URL ได้

แก้แค่ 2 ไฟล์

1. classes/Validate.php

return preg_match('/^[_a-zA-Z0-9\-\pL]+$/u', $link);

แก้เป็น

return preg_match('/^[_a-zA-Z0-9\-\pL\pM]+$/u', $link);

2. classes/Dispatcher.php

แก้ \pL ให้เป็น \pL\pM ทุกอัน (มี 28 อัน)

 

ลองดูนะครับ

Edited by Suthichai (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 2 weeks later...
  • 4 weeks later...

คือผมติดปัญหาอะครับผมใช้ PrestaShop v.1.5.2.0

ผมลองทำตามที่พี่บอกมันใช้ได้แต่ติดปัญหาสองอย่างคือ

1. ผมพิมพ์ domain บน browser มันจะไม่เข้าเว็บ

โดยปกติถ้าพิมพ์ domain แล้วมันจะใส่ /th ให้อัตโนมัติแต่ในกรณีนี้มันไม่ทำ

2. ตอนผม add Catalog Categories พอกดบันทึก มันจะเป็นหน้าขาว ไม่กลับมา

แต่ Categories นั้นถุกสร้างนะครับ

 

ผมเลยทดลองแก้เฉพาะ Dispatcher ก็สามารถเข้า domain ได้ปกติ

Friendly URL ไทยได้ แต่ไม่สามารถสร้าง Categories ได้ครับช่วยด้วยครับผม

Link to comment
Share on other sites

ลองเคลียร์ cookie และ cache ก่อนครับ ทั้ง

  1. Browser cache (Firefox, Internet Explorer, Chome...)
  2. Cache ของ shop : www.your-shop.com/themes/cache/smarty/cache (ลบทุกไฟล์นอกจาก index.php)
  3. Cache ของ shop : www.your-shop.com/themes/cache/smarty/compile (ลบทุกไฟล์นอกจาก index.php)
  4. Cache ของ theme : www.your-shop.com/themes/my_theme/cache (ลบทุกไฟล์นอกจาก index.php)

 

ไม่ได้ยังไงโฟสทลิงค์ด้วยก็ดีครับ สมาชิกท่านอื่นอาจมีคำตอบ

Link to comment
Share on other sites

ก็ยังไม่ได้นะครับ พอกด save ในขั้นตอนไหนก็แล้วแต่ ตัวหน้า browser ก็จะขาวตลอด

Configuration checklist ก็มีฟ้องมาสามตัวครับ

1. แคชของเบราว์เซอร์และการบีบอัด

2. การเพิ่มประสิทธิภาพ Smarty

3. รวมบีบอัดและ Cache

Link to comment
Share on other sites

อย่าเพิ่งใช้ CCC (Combine, Compress and Cache) ให้ disable ก่อนครับ

Force compile, clear cache, refresh (Firefox = Ctrl-F5) รอให้ผ่านก่อนค่อย Enable ก็ได้

 

ผมค่อนข้างมั่นใจว่าใช้กับ 1.5 - 1.5.2.0 ได้

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

ผมยังไม่ได้เปิดเลยนะครับที่ผมเลือกไว้มีดังนี้

Keep CSS as original

Keep JavaScript as original

Keep HTML as original

Keep inline JavaScript in HTML as original

Keep W3C validation

disabled.gif

 

ส่วน Force compile คืออะไรเหรอครับ

แต่ clear cache ผมทำเรียบร้อยแล้ว

ต้องขออภัยจริงๆ ครับพึ่งเริ่มใช้งานนะครับ

Link to comment
Share on other sites

ลองแก้ source code ให้กลับไปเป๋นเหมือนต้นฉบับก่อน แล้วลองดูว่าปกติไหม

ถ้าปกติดีก็แก้โดยการ override ครับ ไม่แนะนำให้แก้ที่ source code โดยตรงครับ วิธีนี้จะสะดวกเวลา upgrade

 

ขั้นตอน

1. override Validate.php โดยการแก้ที่ prestashop/override/classes/Validate.php

<?php

class Validate extends ValidateCore
{
public static function isLinkRewrite($link)
{
	return preg_match('/^[_a-zA-Z0-9\-\pL\pM]+$/u', $link);
}
}

ไม่ต้องปิดด้วย ?>

 

2. override Dispatcher.php โดยการแก้ที่ prestashop/override/classes/Dispatcher.php

<?php

class Dispatcher extends DispatcherCore
{
public $default_routes = array(
	'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\pM]*'),
			'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\pM]*'),
		),
	),
	'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]*'),
		),
	),
	'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',
		),
	),
);
}

ไม่ต้องปิดด้วย ?>

 

ก็สามารถป้อนไทยที่ Friendly URL และแสดงลิงค์เป็นไทย

เฉพาะกับ 1.5 จนถึง 1.5.2.0 แค่นั้นนะ

1.5.3.0 และ 1.5.3.1 ต้องมีการเพ่มฟิลด์ที่ตกหล่นอีก 1 ฟิลด์

Dispatcher.php

Validate.php

Edited by Suthichai (see edit history)
  • Like 1
Link to comment
Share on other sites

ปกติเราสามารถตั้งค่าให้โปรแกรม compile template หรือไม่ ตอนใหน

Force Compilation เป็นการ compile ทุกครั้ง เหมาะเฉพาะกับ website ที่กำลังแก้ไขปรับปรุง

 

Advanced Parameters > Performance > Smarty

Link to comment
Share on other sites

เดี๋ยวขอเวลาเอาไปลองก่อนนะครับ

เมื่อวานไปอัพ theme แล้วเว็บเจ๊งเดี๋ยวลงใหม่แล้วจะทดสอบ

แล้วจะมาแจ้งผลให้พี่ทราบอีกที

ต้องขอบคุณพี่มากเลยครับที่ช่วยเหลือ

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

  • 7 months later...
  • 7 months later...
  • 7 months 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...