jigniter™

jQuery & CodeIgniter – Perfect combination for web application

Archive for the ‘uri’ tag

Using url_title() with Spanish or other strange characters

with 3 comments

If you are running your site in Spanish and using url_title to create Permalinks in CodeIgniter then likely you had run in character issues while creating your links.

Martin posted a solution in CodeIgniter’s forum with a workaround for this issue. He proposed


$trans = array(
                    $search                                => $replace,
                    "á"                                    => 'a',
                    "é"                                    => 'e',
                    "í"                                    => 'i',
                    "ó"                                    => 'o',
                    "ú"                                    => 'u',
                    "à"                                    => 'a',
                    "è"                                    => 'e',
                    "ì"                                    => 'i',
                    "ò"                                    => 'o',
                    "ù"                                    => 'u',
                    "ñ"                                    => 'n',
                    "ä"                                    => 'a',
                    "ë"                                    => 'e',
                    "ï"                                    => 'i',
                    "ö"                                    => 'o',
                    "ü"                                    => 'u',
                    "\s+"                                => $replace,
                    "[^a-z0-9".$replace."]"                => '',
                    $replace."+"                        => $replace,
                    $replace."$"                        => '',
                    "^".$replace                        => ''
                   );

My two cents here are the following. You can try to override the URL Helper by extending it in MY_url_helper.php under application/helpers directory.

Written byadmin

March 14th, 2010 at 8:51 am

How to submit a page to the same controller in CodeIgniter

with 2 comments

Imagine you have a view with a <FORM> that need to submit to the same controller class. Probably you don’t want to hardcode the action attribute of your form nor leaving it in blank.

Using PHP_SELF could be a possible approach. However, since $_SERVER[‘PHP_SELF’] is a PHP server variable (nothing to do with CodeIgniter), you may encounter some problems with different environments.

So, why not to use the built-in CodeIgniter URI library? My solution to this problem is the following. Use $this->uri->uri_string() in conjunction with site_url().

Here is a simple example:



Written byadmin

July 17th, 2009 at 11:23 am

Posted inSnippets Ideas

Tagged with ,