strlen()是用來計算字符串的字數,而實際上它是計算字符串的位元組。
由於UTF-8拉丁字母只佔一個位元組,而UTF-8漢字佔三個位元組,所以strlen()會將2個UTF-8漢字視為6個字符,而2個拉丁字母仍然是2個字符。以上修正方法同樣適用於 Attribute Group Name 和 Manufacturer Name ,只要照辦煮碗編輯程式碼便可。
Attribute Group Name: [admin/controller/catalog/attribute_group.php]
Manufacturer Name: [admin/controller/catalog/manufacturer.php]
<p>
<!--<br />
Make sure that you have properly installed Opencart vQmod.<br />
Copy this page of script.<br />
Save as a .xml file of utf-8 encoding without BOM into the directory [vqmod/xml].<br />
Name the file as you like.<br />
--></p>
<pre contenteditable="true">
<?xml version="1.0" encoding="utf-8"?>
<modification>
<id>Allow attribute name of 2 charcters</id>
<version>1.0.0</version>
<author>Flexidigi Solution Ltd</author>
<file name="admin/controller/catalog/attribute.php">
<operation error="skip">
<search position="replace"><![CDATA[utf8_strlen($value['name']) < 3]]></search>
<add><![CDATA[strlen($value['name']) < 3]]></add>
</operation>
</file>
<file name="admin/controller/catalog/attribute_group.php">
<operation error="skip">
<search position="replace"><![CDATA[utf8_strlen($value['name']) < 3]]></search>
<add><![CDATA[strlen($value['name']) < 3]]></add>
</operation>
</file>
<file name="admin/controller/catalog/manufacturer.php">
<operation error="skip">
<search position="replace"><![CDATA[utf8_strlen($value['name']) < 3]]></search>
<add><![CDATA[strlen($value['name']) < 3]]></add>
</operation>
</file>
</modification></pre>
0 comments:
Post a Comment