Mod_Rewrite and Accents - eSyndiCat User Forums
eSyndiCat User Forums esyndicat directory software esyndicat support

Go Back   eSyndiCat User Forums > eSyndiCat Directory Software [FREE] > Modifications

Modifications Simple to complex modifications, made by users or by our team, applied to logic or presentation, all kinds of modifications are discussed and requested here.

Reply
 
Thread Tools Display Modes
Old 08-12-2006   #1
neominds
 
Join Date: Feb 2006
Location: Mexico City
Posts: 53
neominds has disabled reputation
Default Mod_Rewrite and Accents

I was wondering if it si possible to program the mod_rewrite in a way that accents are converted to normal letters. The problem that I have is that I have some titles that use accents. This is no problem, but when the link is written it just writes a - in the url.

For example I have one link that is called: Herramientas Electrónicas

Here you can see that Electrónicas uses an ó with an accent. If I enter the pages which contains the details of that link it converts that ó to -

So it is like this:

herramientas-electr-nicas-l2046.html

Is it possible to convert that - to an o without an accent?? Actually I need to convert these accents:

á=>a, é=>e, í=>i, ó=>o, ú=>u, ñ=>n

Does anyone know how to program these modifications??

Thanks,


Richard
neominds is offline   Reply With Quote
Old 08-12-2006   #2
Sergey Ten
eSyndiCat Lead Developer
 
Sergey Ten's Avatar
 
Join Date: Apr 2006
Location: Kyrgyzstan, Bishkek
Posts: 6,596
Sergey Ten is a jewel in the roughSergey Ten is a jewel in the roughSergey Ten is a jewel in the roughSergey Ten is a jewel in the rough
Default

Hello Richard,

Please try make this:

*** Open your util.php ***
*** Find this function ***

PHP Code:
/**
* Converts string to url valid string
*
* @param arr $aParams text string
*
* @return str
*/
function convert_str($aParams)
{
    
$aParams['string'] = strtolower($aParams['string']);
    
$aParams['string'] = preg_replace('/[^a-z0-9]+/i''-'$aParams['string']);
    
$aParams['string'] = preg_replace('/\-+/''-'$aParams['string']);
    
$aParams['string'] = trim($aParams['string'], '-');

    return 
$aParams['string'];

*** Replace with ***

PHP Code:
/**
* Converts string to url valid string
*
* @param arr $aParams text string
*
* @return str
*/
function convert_str($aParams)
{
    
$aParams['string'] = strtolower($aParams['string']);
    
    
$aParams['string'] = str_replace('your letter a''a'$aParams['string']);
    
$aParams['string'] = str_replace('your letter e''e'$aParams['string']);
    
$aParams['string'] = str_replace('your letter i''i'$aParams['string']);
    
$aParams['string'] = str_replace('your letter o''o'$aParams['string']);
    
$aParams['string'] = str_replace('your letter u''u'$aParams['string']);
    
$aParams['string'] = str_replace('your letter n''n'$aParams['string']);
    
    
$aParams['string'] = preg_replace('/[^a-z0-9]+/i''-'$aParams['string']);
    
$aParams['string'] = preg_replace('/\-+/''-'$aParams['string']);
    
$aParams['string'] = trim($aParams['string'], '-');

    return 
$aParams['string'];

*** Save change ***

You have to change on your specific letters.

And plase post the result.
Sergey Ten is offline   Reply With Quote
Old 08-14-2006   #3
neominds
 
Join Date: Feb 2006
Location: Mexico City
Posts: 53
neominds has disabled reputation
Default

Quote:
Originally Posted by Sergey Ten
Hello Richard,

Please try make this:

*** Open your util.php ***
*** Find this function ***

PHP Code:
/**
* Converts string to url valid string
*
* @param arr $aParams text string
*
* @return str
*/
function convert_str($aParams)
{
    
$aParams['string'] = strtolower($aParams['string']);
    
$aParams['string'] = preg_replace('/[^a-z0-9]+/i''-'$aParams['string']);
    
$aParams['string'] = preg_replace('/\-+/''-'$aParams['string']);
    
$aParams['string'] = trim($aParams['string'], '-');

    return 
$aParams['string'];

*** Replace with ***

PHP Code:
/**
* Converts string to url valid string
*
* @param arr $aParams text string
*
* @return str
*/
function convert_str($aParams)
{
    
$aParams['string'] = strtolower($aParams['string']);
    
    
$aParams['string'] = str_replace('your letter a''a'$aParams['string']);
    
$aParams['string'] = str_replace('your letter e''e'$aParams['string']);
    
$aParams['string'] = str_replace('your letter i''i'$aParams['string']);
    
$aParams['string'] = str_replace('your letter o''o'$aParams['string']);
    
$aParams['string'] = str_replace('your letter u''u'$aParams['string']);
    
$aParams['string'] = str_replace('your letter n''n'$aParams['string']);
    
    
$aParams['string'] = preg_replace('/[^a-z0-9]+/i''-'$aParams['string']);
    
$aParams['string'] = preg_replace('/\-+/''-'$aParams['string']);
    
$aParams['string'] = trim($aParams['string'], '-');

    return 
$aParams['string'];

*** Save change ***

You have to change on your specific letters.

And plase post the result.
Thanks Sergey I got it working...

Cheers,


Richard Meijs
neominds is offline   Reply With Quote
Old 11-23-2007   #4
itramways
 
itramways's Avatar
 
Join Date: Nov 2006
Location: Paris, France
Posts: 40
itramways is on a distinguished road
Default

Hello,

I would do the same thing with version 2.2.
I tried, but it does not work.

Thank you for yours answers.

Regards

Jc
__________________
http://www.itramways.net
itramways is offline   Reply With Quote
Old 06-22-2012   #5
neominds
 
Join Date: Feb 2006
Location: Mexico City
Posts: 53
neominds has disabled reputation
Default

Quote:
Originally Posted by itramways View Post
Hello,

I would do the same thing with version 2.2.
I tried, but it does not work.

Thank you for yours answers.

Regards

Jc
How can this be done with the 2.4.1 script?? I need lowercases and to convert á to a in the url and any other accent... The tried the solutions and changing it in the util.php but it didnt work out...
neominds is offline   Reply With Quote
Old 11-28-2007   #6
Vasily B.
Administrator
 
Vasily B.'s Avatar
 
Join Date: Sep 2005
Posts: 9,299
Vasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished road
Default

Hi
In our 2.2 version this function is called

function convertStr($str)

So please try to make similar changes in this function. You can find it in includes/util.inc.php
__________________
Subrion CMS - free open source php content management system
Business Directory Script - powerful php business directory software, Yellow Pages Script - the most advanced yellow pages php software
Vasily B. is offline   Reply With Quote
Old 11-28-2007   #7
itramways
 
itramways's Avatar
 
Join Date: Nov 2006
Location: Paris, France
Posts: 40
itramways is on a distinguished road
Default

Hello, thank you for your ansver,

In includes/util.php (there is no util.inc.php), I do this modification :

PHP Code:
    function convertStr($str)
    {
        
$str['string'] = str_replace('é''e'$str['string']);
        
$str['string'] = str_replace('è''e'$str['string']);
        
$str['string'] = str_replace('ê''e'$str['string']);
        
$str['string'] = str_replace('ë''e'$str['string']);
        
$str['string'] = str_replace('à''a'$str['string']);
        
$str['string'] = str_replace('ñ''n'$str['string']);
        
$str['string'] = str_replace('ù''u'$str['string']);
        
$str['string'] = str_replace('ú''u'$str['string']);
        
$str['string'] = str_replace('û''u'$str['string']);
        
$str['string'] = str_replace('ü''u'$str['string']);
        
$str['string'] = str_replace('ë''e'$str['string']);
        
$str['string'] = str_replace('à''a'$str['string']);        
        
        
$str preg_replace('/[^a-z0-9]+/i''-'$str);
        
$str preg_replace('/\-+/''-'$str);
        
$str trim($str'-');
    
        return empty(
$str) ? "listing" $str;
    } 
It does not work

Regards
Jc
__________________
http://www.itramways.net
itramways is offline   Reply With Quote
Old 11-28-2007   #8
Vasily B.
Administrator
 
Vasily B.'s Avatar
 
Join Date: Sep 2005
Posts: 9,299
Vasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished roadVasily B. is on a distinguished road
Default

Uff my answer was not complete

Please try to change your $str array to $str variable

$str['string'] should be simply $str instead
__________________
Subrion CMS - free open source php content management system
Business Directory Script - powerful php business directory software, Yellow Pages Script - the most advanced yellow pages php software
Vasily B. is offline   Reply With Quote
Old 11-28-2007   #9
itramways
 
itramways's Avatar
 
Join Date: Nov 2006
Location: Paris, France
Posts: 40
itramways is on a distinguished road
Default

I try this code :

PHP Code:
function convertStr($str)
{
        
$str str_replace('é''e'$str);
        
$str str_replace('è''e'$str);
        
$str str_replace('ê''e'$str);
        
$str str_replace('ë''e'$str);
        
$str str_replace('à''a'$str);
        
$str str_replace('ñ''n'$str);
        
$str str_replace('ù''u'$str);
        
$str str_replace('ú''u'$str);
        
$str str_replace('û''u'$str);
        
$str str_replace('ü''u'$str);
        
$str str_replace('ë''e'$str);
        
$str str_replace('à''a'$str);
        
$str str_replace('ç''c'$str);

        
$str preg_replace('/[^a-z0-9]+/i''-'$str);
    
$str preg_replace('/\-+/''-'$str);
    
$str trim($str'-');
    
    return empty(
$str) ? "listing" $str;

It does not work.
Despite my research on Google, I did not find a solution
Regards
Jc
__________________
http://www.itramways.net
itramways is offline   Reply With Quote
Old 11-29-2007   #10
Dave Baker
 
Join Date: Jul 2006
Location: St. Petersburg
Posts: 2,567
Dave Baker is on a distinguished road
Default

Hello itramways,
***Open includes/classes/esynSmarty.php and find code***
Code:
	function convertStr($aParams)
	{
		$aParams['string'] = preg_replace('/[^a-z0-9]+/i', '-', $aParams['string']);
		$aParams['string'] = preg_replace('/\-+/', '-', $aParams['string']);
		$aParams['string'] = trim($aParams['string'], '-');
	
		return empty($aParams['string']) ? "listing" : $aParams['string'];
	}
***Replace with***
Code:
	function convertStr($aParams)
	{
		esynLoadUTF8Util('utf8_to_ascii');
		$aParams['string'] = utf8_to_ascii($aParams['string']);
		
		$aParams['string'] = preg_replace('/[^a-z0-9]+/i', '-', $aParams['string']);
		$aParams['string'] = preg_replace('/\-+/', '-', $aParams['string']);
		$aParams['string'] = trim($aParams['string'], '-');
	
		return empty($aParams['string']) ? "listing" : $aParams['string'];
	}
***Save file***

It should work
Dave Baker is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 02:22 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Testimonials | Articles | Support | Documentation | Privacy Policy | License | Affiliates | Contact Us