*

officela

  • ***
  • 64 posts
Greek chracters in url (cyrilic)
« on: November 10, 2020, 11:42:45 AM »
Greetings,

Until osclass 3.8 i had this fix for creating latin url our of the Greek characters of the listing title to the url.

1.- Look in oc-includes/osclass/helpers/hDefines.php for:


Code: [Select]
$url = str_replace('{ITEM_TITLE}', osc_sanitizeString($item['s_title']), $url);
and replace it with:


Code: [Select]
$url = str_replace('{ITEM_TITLE}', osc_sanitizeString( cust_cyrillic_to_latin($item['s_title']) ), $url);
Now, being a core file, remember that you need to redo this modification every time you upgrade Osclass.

2.- Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_cyrillic_to_latin($textcyr) {
    
$cyr  = array('α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','п','ρ','σ','τ','υ',
        
'φ','χ','ψ','ω','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ',
        
'Φ','Χ','Ψ','Ω','ί','ό','ώ','ά','ή','έ','€');
    
$lat = array( 'a','b','g','d','e','z','i','th','i','k','l','m','n','x','o','p','r','s','t','y',
        
'f' ,'x' ,'ps' ,'w','A','B','G','D','E','Z','I',
        
'TH','I','K','L','M','N','X','O','P','R','S','T','Y',
        
'F' ,'X' ,'Ps' ,'W' ,'i' ,'ο' ,'w''a''h''e''euro');

    return 
str_replace($cyr$lat$textcyr); 
}
?>



And it was working until i updated to the osclass 4.1.1.....
At the new version oc-includes/osclass/helpers/hDefines.php as follows bellow can you please tell me how i need write the old

Code: [Select]
$url = str_replace('{ITEM_TITLE}', osc_sanitizeString( cust_cyrillic_to_latin($item['s_title']) ), $url);      in order to work???



New code bellow as in hDefines.php in versions 4.1.1

Code: [Select]
/**
* Create automatically the url of the item details page
*
* @param string $locale
* @return string
* @throws \Exception
*/
    function osc_premium_url($locale = '') {
        if ( osc_rewrite_enabled() ) {
            $sanitized_categories = array();
            $cat = Category::newInstance()->hierarchy(osc_premium_category_id());
            for ($i = count( $cat); $i > 0; $i--) {
                $sanitized_categories[] = $cat[$i - 1]['s_slug'];
            }
            $url = str_replace( array ( '{ITEM_ID}' , '{CATEGORIES}' ) , array (
            osc_premium_id() ,
            implode( '/' , $sanitized_categories )
            ) , str_replace( '{ITEM_TITLE}', osc_sanitizeString( str_replace( ',', '-', osc_premium_title())), osc_get_preference( 'rewrite_item_url')) );
            if($locale!='') {
                $path = osc_base_url().$locale . '/' . $url;
            } else {
                $path = osc_base_url().$url;
            }
        } else {
            $path = osc_item_url_ns( osc_premium_id(), $locale );
        }
        return $path;
    }
« Last Edit: November 10, 2020, 01:44:04 PM by MB Themes »

*

MB Themes

Re: Greek Chracters and url
« Reply #1 on: November 10, 2020, 12:10:17 PM »
@officela
Why you was doing that? if you server supports that, URL will work with cyrilic, latin, arabic, azbuka, japanese, chinese chars...
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

officela

  • ***
  • 64 posts
Re: Greek Chracters and url
« Reply #2 on: November 10, 2020, 12:33:14 PM »
it was never server issue. maybe because i have main language the Greek? i don't really know :)

What i know, is that only this way the url was good.

Now the urls are like this : ό-50-ί-ά-Ά-ύ_id1155   ( this is coming from the title in wrong way and the id that is correct )

when having greek characters i get those strange things....


And if not make it work i will have to go back to old version and better i do not do that. I feel this version 4.1.1 is way better from 3.8.


*

MB Themes

Re: Greek chracters in url (cyrilic)
« Reply #3 on: November 10, 2020, 01:48:39 PM »
@officela
From my experience, basically if you have special character like those you mentioned in URL and your server does not support it (or does not have it enabled), then you should get something like redirect error (this page has tried to redirect you too many times).
You may see it as example there:
https://demo.osclasspoint.com/search/pattern,%CF%8C-50-%CE%AF-%CE%AC-%CE%86-%CF%8D

But that would mean (your conversion) that you cannot really search based on cyrilic characters at all on your site.
If you look on screenshot I've attached of one website using arabic characters those are supported by server, you will see it's working properly.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

officela

  • ***
  • 64 posts
Re: Greek chracters in url (cyrilic)
« Reply #4 on: November 10, 2020, 01:58:17 PM »
https://demo.osclasspoint.com/for-sale/barter/_i23


At the demo you send me i added a new listing with Greek title. The same!
The url just shows the _i23 that this is the listing ID.....

I do not want to search with text... i have removed that function....
In the same server i have wordpress etc and greek works great but as i am telling you the server is not the case.....


I just need your help where to put and how this ?
Code: [Select]
$url = str_replace('{ITEM_TITLE}', osc_sanitizeString( cust_cyrillic_to_latin($item['s_title']) ), $url);
at the hDefines.php   as now you've changed a lot and i can't replace like i did in the older version....

*

MB Themes

Re: Greek chracters in url (cyrilic)
« Reply #5 on: November 10, 2020, 04:07:56 PM »
@officela
I've sent you how it works on upcoming osclass version.
hDefines has not changed, function is still there:
Code: [Select]
function osc_item_url_from_item($item, $locale = '')
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots