Automatic change of 'page alias' for slovak, czech, and other languages

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
roman
Forum Members
Forum Members
Posts: 77
Joined: Thu May 12, 2005 9:38 am

Automatic change of 'page alias' for slovak, czech, and other languages

Post by roman »

When you create a new page, after send form, you must change page alias - remove  characters "?"...
Way is change file "lib/classes/class.content.inc.php" ... after line 341 ("$alias = trim($this->mMenuText);") put:

Code: Select all

#Change letters with diacritic
$badletters = array("ľ", "š", "č", "ť", "ž", "ý", "á", "í", "é", "ú", "ä", "ô", "ň", "ď", "ů", "ř", "ě");
$goodletters =array("l", "s", "c", "t", "z", "y", "a", "i", "e", "u", "a", "o", "n", "d", "u", "r", "e");
$alias = strtolower(str_replace($badletters, $goodletters, $alias));
mbvdk
Forum Members
Forum Members
Posts: 43
Joined: Wed Jun 08, 2005 3:30 pm

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by mbvdk »

Looks like a simple solution, but it has one drowback: when the user creates a page name that contains a character that is not on the list, you still get an invalid alias.

What I do is disable alias auto-generation, setting

Code: Select all

$config['auto_alias_content'] = false; 
in "config.php"

Not elegant, but now it's the users fault if the alias isn't valid ;)
roman
Forum Members
Forum Members
Posts: 77
Joined: Thu May 12, 2005 9:38 am

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by roman »

Yes, but before my solution was also this problem, and now, if y will fill into this arrays letters from your language can be good. Not?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by Ted »

If I were going to do something like this, it would have to be on a language by language basis and actually defined in the nls file for that language.

I'm not opposed to that, though.  Lemme think about it.
roman
Forum Members
Forum Members
Posts: 77
Joined: Thu May 12, 2005 9:38 am

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by roman »

I'm not opposite :), settings can by in 'User Preferences' admin part,if y like this system, or default, or not 'auto_alias_content' ... Also in user preferences somebody had question about numbers of pages displayed per mangement of pages in file 'admin/listcontent.php' ...default is 20. This file ('admin/editprefs.php') can be automatic generated from database for furhter inflation. .... but maybe don't will be cms MADE SIMPLE :)
ToOb

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by ToOb »

Ted wrote: If I were going to do something like this, it would have to be on a language by language basis and actually defined in the nls file for that language.
Definition table used in Textpattern (for "all" languages globally):
http://txpref.avinnovators.com/textpatt ... source.txt

PHP function utilizing it:
http://txpref.avinnovators.com/textpatt ... .html#l561
(Don't ask me why is called dumbdown. :)
Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by Wiedmann »

Hi Karolis,

you can try the attached  patch. (at the current date, I assume that your PHP have the iconv-extension installed...)

Regards,
Carsten
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by Wiedmann »

And I still get the following error when adding page with Russian characters:
Can you give me an example of such a Russian page name?
Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by Wiedmann »

Thanks, and I've found the problem... iconv also does not have a translation table for any of these characters (the chars from "roman" all work fine...). Thus these chars can't be translit to another charset (they have no similar expression) and so the remaining string is empty.

Three ways are possible
- you can enhance the file "replacement.php" with all Cyryllic chars you are using
- cmsms is using a unique random string as page alias instead (need patch)
- use the Cyryllic chars (any utf-8 char) as page alias. (need patch)
Wiedmann
Forum Members
Forum Members
Posts: 233
Joined: Wed Mar 26, 2008 1:49 am

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by Wiedmann »

can you provide me with the links to the patches you've mentioned?
Oh, if you need one of them, I must first write the patch ;-)
Sonya

Re: Automatic change of 'page alias' for slovak, czech, and other languages

Post by Sonya »

I solved it with translit lib and UDT (russian) http://forum.cmsmadesimple.org/index.ph ... 132.0.html

Probably a solution for you too.
Last edited by Sonya on Thu Jun 12, 2008 1:20 pm, edited 1 time in total.
Post Reply

Return to “Tips and Tricks”