Zen Cart Logo
Forums / General Questions / Need Help converting Javascript to PHP

Need Help converting Javascript to PHP

Locked

Views: 903

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
28 Jul 2008, 11:32 PM
#1
nguyenkhv avatar

nguyenkhv

New Zenner

Join Date:
Feb 2008
Posts:
35
Plugin Contributions:
0

Need Help converting Javascript to PHP

Hello,
I have installed the latest ZC.
I have modified the html_header.php file in the inclues/templates/template-default/common folder so that a javascript will strip all special non alphabetical of the store item's name before write it to the page title:
Bellow is the code in the header section of the file:

<script language="JavaScript" runat="server"> document.title=StripUnicode('<?php echo META_TAG_TITLE; ?>') function StripAll() { document.myForm.Keyword.value = StripUnicode(document.myForm.vArea.value) } function StripUnicode(textString) { var returnValue = "" var uFont = textString.toLowerCase() for (var i=0; i< uFont.length; i++) { returnValue += stripThis(escape(uFont.charAt(i))) } return returnValue } function stripThis(uniCode) { var a = "%E1%E0%E3%u1EA1%E2%u1EA5%u1EA7%u1EAB%u1EAD%u0103%u1EAF%u1EB1%u1EB5%u1EB7%u1EA3%u1EA9%u1EB3" var e = "%E9%E8%u1EBD%u1EB9%u1EBF%u1EC1%u1EC5%u1EC7%EA%u1EC3%u1EBB" var i = "%ED%EC%u0129%u1ECB%u1EC9" var o = "%F3%F2%F5%u1ECD%F4%u1ED1%u1ED3%u1ED7%u1ED9%u01A1%u1EDB%u1EDD%u1EE1%u1EE3%u1ED5%u1EDF%u1ECF" var u = "%FA%F9%u0169%u1EE5%u01B0%u1EE9%u1EEB%u1EEF%u1EF1%u1EE7%u1EED" var y = "%FD%u1EF3%u1EF9%u1EF5%u1EF7" var d = "%u0111" var returnValue var bIsFound = false if (uniCode.charAt(0) == "%") { if (a.indexOf(uniCode) !=-1) {returnValue = "a"; bIsFound = true} if (!bIsFound){ if (e.indexOf(uniCode) !=-1) {returnValue = "e"; bIsFound = true}} if (!bIsFound){ if (i.indexOf(uniCode) !=-1) {returnValue = "i"; bIsFound = true}} if (!bIsFound){ if (o.indexOf(uniCode) !=-1) {returnValue = "o"; bIsFound = true}} if (!bIsFound){ if (u.indexOf(uniCode) !=-1) {returnValue = "u"; bIsFound = true}} if (!bIsFound){ if (y.indexOf(uniCode) !=-1) {returnValue = "y"; bIsFound = true}} if (!bIsFound){ if (d.indexOf(uniCode) !=-1) {returnValue = "d"; bIsFound = true}} } if (!bIsFound) returnValue = unescape(uniCode) return returnValue } </script>

Here is the problem:
Google bot doesn't recognize the title produced by the javascript, and therefore did not index the page title corretly. (it indexed the page title as : "categories" in the Google search result page)


I dont know any thing about php, and therefore, cannot customize the php to strip the unicode like the javascript does above.
Can someone please help me with converting or write a similar php code to work like the javascript function bove.
thanks for all help and suggestions.
nguyen