News:

Looking for documentation? Take a look on our wiki

Main Menu

Unicode

Started by Servelatin, April 23, 2014, 08:17:48 AM

Previous topic - Next topic

Servelatin

Joomla 2.5
VM 2.6
PHP 5.3.3
------------------
Hello. I use unicode aliases in product slugs (Russian). After 2.6 update VM automatically changes to the transliteration while maintaining product, I have to manually change the value in the database. Before the upgrade worked well.

SEO Settings of Joomla:
Search Engine Friendly URLs - yes
Use URL rewriting - yes
Adds Suffix to URL - no
Unicode Aliases - yes

Seo setting of VM:
SEO Disabled - no
Seo Suffix - .html
Translate Strings - yes
Use Product and Category IDs - no

What is wrong ?

Milbo

/administrator/components/com_virtuemart/helpers/vmtable.php

around line 719


//$config =& JFactory::getConfig();
//$transliterate = $config->get('unicodeslugs');
$transliterate = VmConfig::get('transliterateSlugs',true);
if($transliterate){
$lang = JFactory::getLanguage();
$this->$slugName = $lang->transliterate($this->$slugName);
}


There was some probleme with using the joomla config "use unicode alias". It should help to open your virtuemart.cfg and to add transliterateSlugs=0, then go to your vm config and store it one time. Then it should be gone. But the problem left is then


$this->$slugName = urlencode($this->$slugName);


I am happy, if we can work that out. Maybe you can also just decomment the lines and use the joomla config.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emuleb

We have the same problem here....
Even when you search your product SKU number with "-" dashes in it, you get a 404-error

And we've noticed that the Alias on each product constantly changes when you save the product.

For example:
1th save the product alias will be : "asrock+fm2a78m+pro4%2B"
2th save the product alias will be : "asrock%2Bfm2a78m%2Bpro4%252b"   -> we did not make any change on the product.


Milbo

#3
What is the original slug you want to store? emuleb, the problem you describe is another one. Your problem is that you want to use chars which work, but which are not "official" for php and therefore get converted.
The function creates/checks a slug this way:


//Change all spaces into -
$this->$slugName = str_replace('-', ' ', $this->$slugName);

//if transliterate /unicode is activated, transliterate first
$transliterate = VmConfig::get('transliterateSlugs',true);
if($transliterate){
$lang = JFactory::getLanguage();
$this->$slugName = $lang->transliterate($this->$slugName);
}

// Trim white spaces at beginning and end of alias and make lowercase
$this->$slugName = trim(JString::strtolower($this->$slugName));

//Filter the input for safety, do not replace - _ . |, else replace all filtered by -
$this->$slugName = vRequest::filterUword($this->$slugName,'-,_,.,|','-');

//Remove all doubled -- (we may do that also with _ and so on )
while(strpos($this->$slugName,'--')){
$this->$slugName = str_replace('--','-',$this->$slugName);
}

// Trim dashes at beginning and end of alias
$this->$slugName = trim($this->$slugName, '-');

$this->$slugName = urlencode($this->$slugName);


The problem of Servelatin should be solved by configuring 'transliterateSlugs' to false =>'transliterateSlugs'=1 in the virtuemart.cfg. The problem described by emuleb comes from the last line $this->$slugName = urlencode($this->$slugName); maybe it is actually rawurlencode, or we must add a config setting for it.

But I get for srock+fm2a78m+pro4%2B => srock-fm2a78m-pro4-2b, so I do not really understand the problem of emuleb.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

I think now that is the right way to go


$unicodeslugs = VmConfig::get('transliterateSlugs',false);
if($unicodeslugs){
$lang = JFactory::getLanguage();
$this->$slugName = $lang->transliterate($this->$slugName);
}

// Trim white spaces at beginning and end of alias and make lowercase
$this->$slugName = trim(JString::strtolower($this->$slugName));
$this->$slugName = str_replace(array('`','´',"'"),'',$this->$slugName);

$this->$slugName = vRequest::filterUword($this->$slugName,'-,_,.,|','-');
while(strpos($this->$slugName,'--')){
$this->$slugName = str_replace('--','-',$this->$slugName);
}
// Trim dashes at beginning and end of alias
$this->$slugName = trim($this->$slugName, '-');

if($unicodeslugs) $this->$slugName = rawurlencode($this->$slugName);
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

emuleb

Hello Milbo,


I try to follow you, but wich file we've to modify for solving our problem?

emuleb

Sorry our problem is solved, we've removed the // on line 713 and 714, and the problem is gone.....

         if (JVM_VERSION === 1) $this->$slugName = JFilterOutput::stringURLSafe($this->$slugName);
         else $this->$slugName = JApplication::stringURLSafe($this->$slugName);
         //pro+#'!"§$%&/()=?duct-w-| ||cu|st|omfield-|str<ing>
         //vmdebug('my slugName '.$slugName,$this->$slugName);
         $this->$slugName = str_replace('-', ' ', $this->$slugName);

         $lang = JFactory::getLanguage();
         $this->$slugName = $lang->transliterate($this->$slugName);
         //vmdebug('my slug after transliterate ',$this->slug);
         // Trim white spaces at beginning and end of alias and make lowercase
         $this->$slugName = trim(JString::strtolower($this->$slugName));
         $this->$slugName = str_replace(array('`','´',"'"),'',$this->$slugName);

illusiondrmr

#7
Hello,

I think i got a similar problem. I use greek characters for the product alias.
However, after 2.6.0 when i save a new product the product alias looks like : campus-t-shirt-%CE%B3%CF%85%CE%BD%CE%B1%CE%B9%CE%BA%CE%B5%CE%B9%CE%BF-150018

That results in a 404 error in front of the shop. My old products still got the greek letters in the product alias and work fine. (however, if i change anything and press SAVE then i got the problem there as well). The problem is after 2.6.0 when i add a new product as mentioned above.

Joomla SEO :
Search Engine Friendly URLs   Yes
Use URL rewriting   Yes
Adds Suffix to URL   No
Unicode Aliases   Yes

VM SEO : Nothing check and -detail.

UPDATE : If i SAVE the product again then the product alias looks like : campus-t-shirt-ce-b3-cf-85-ce-bd-ce-b1-ce-b9-ce-ba-ce-b5-ce-b9-ce-bf-150018 and then it wont generate 404 anymore, but the problem still exists that i cant add greek characters in my product's alias.

I tried to add : transliterateSlugs=0 to my virtuemart.cfg but it didnt help.

Milbo

Quote from: illusiondrmr on April 28, 2014, 13:05:04 PM
I tried to add : transliterateSlugs=0 to my virtuemart.cfg but it didnt help.

you must store your vm config, to get the values of the file.

Please try the code I posted above, everything should work then as before.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

illusiondrmr

Ιm a bit messed up with which code to copy paste in the vmtable.php. Is it possible to attach a correct vmtable.php file to download ?

Thank you !

liotropi

Thanks Milbo  :)

this was driving me crazy

illusiondrmr -
file: administrator/components/com_virtuemart/helpers/vmtable.php

I commented out lines 713 - 734 

(from //if (JVM_VERSION  and ends with //vmdebug('my slug after urlencode ',$this->slug);

and inserted Milbo's code

and the urls are being generated like before
VM 2.6.0
Joomla! 2.5.16
PHP Version 5.3.27

Milbo

Well, thank you liotropi.

We are going to upload a vm2.6a soon.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

illusiondrmr

Thank you very much both of you.
Problemo solved.

iRescue.gr

Hello to all!

I am trying to fix this problem some time now, but it seems that i am missing something.

Is there any chance of writing the solution in a more specific way?
Which lines of code do i replace and what's the code i add?

Thanks in advance!

Milbo

Just upload the files to /administrator/components/com_virtuemart/helpers

[attachment cleanup by admin]
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/