ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

URI Language Identifier

April 09, 2008 11:45pm

Subscribe [14]
  • #61 / Jul 29, 2008 1:26pm

    lizaaard

    17 posts

    thanks… i’ll try the new version =)

  • #62 / Aug 22, 2008 1:42pm

    abmcr

    254 posts

    I have set into the routes a code as

    <?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
    //route example: <a href="http://domain.tld/en/controller">http://domain.tld/en/controller</a> => <a href="http://domain.tld/controller">http://domain.tld/controller</a>
    $route['(\w{2})/(.*)'] = "home/index/$2";
    ?>

    With this URL

    <a href="http://localhost:8888/CI16/en/la_struttura">http://localhost:8888/CI16/en/la_struttura</a>

    i get the home/index function where “la_struttura” is used as uri segment for quering databases. All work.
    My problem is:
    into the view i build the href with anchor function, for example

    <a href="http://localhost:8888/CI16/prova">http://localhost:8888/CI16/prova</a>

    but when i clik into the link the url not appear as

    <a href="http://localhost:8888/CI16/en/prova">http://localhost:8888/CI16/en/prova</a>

    ... but as

    <a href="http://localhost:8888/CI16/prova">http://localhost:8888/CI16/prova</a>

    .
    What is th error? Thank you in advance

  • #63 / Aug 23, 2008 5:22am

    abmcr

    254 posts

    I have solved myself: the problem was

    $config['lang_ignore'] = "it";

    if i remove this line as

    $config['lang_ignore'] = "pl";

    all work

  • #64 / Aug 25, 2008 7:40am

    abmcr

    254 posts

    I have a problem ... i have set this routes and i test with http://www.myurl.com/it or www.myurl.com/en

    $route['(\w{2})/home/link/(.*)'] = "home/link/$2";
    $route['(\w{2})'] = $route['default_controller'];
    $route['(\w{2})/contatti'] = "contatti";
    $route['(\w{2})/mappa'] = "home/mappa";
    $route['(\w{2})/news'] = "news";
    $route['(\w{2})/pdf/(.*)'] = "home/pdf/$2";
    $route['(\w{2})/photogallery'] = "gallerie";
    $route['(\w{2})/ricerca'] = "ricerca/index";
    $route['(\w{2})/ricerca/(.*)'] = "ricerca/index/$2";
    $route['(\w{2})/stampa/(.*)'] = "home/stampa/$2";
    $route['(\w{2})/tag/(.*)'] = "tag/index/$2";
    $route['(\w{2})/(.*)'] = "home/index/$2";
    $route['(\w{2})'] = $route['default_controller'];
    $route['default_controller'] = "home/base";

    All work fine, but if i type only
    http://www.myurl.com/
    without an language identifier my defauklt controller is not loaded.
    I have set a html file with a 301 HEADER, but it is possible to set a route for managing the site_url without language extension?
    Thank you

  • #65 / Sep 30, 2009 11:25am

    wiredesignz

    2882 posts

    URI Language Identifier version 0.21 is now available on the wiki

    Updated to allow using the same uri->segment() count with or without the library installed, making it less intrusive.

    Note: the language uri segment is removed. Use config->item(‘language’) or ‘lang_abbr’ to determine the active language.

  • #66 / Oct 09, 2009 12:29am

    wiredesignz

    2882 posts

    URI Language Identifier version 0.22 is now available on the wiki

  • #67 / Dec 04, 2009 11:56am

    fromjah

    5 posts

    Hi,

    I’m using the URI Language Identifier v0.22 with the url helper (that produce the alt_site) on the last CI version.

    It works fine as long as there is not the language uri somewhere else in the link:

    Explanation:
    http://example.com/mycontroller/myfunction/
    http://example.com/gl/mycontroller/myfunction/

    this will works just fine but if you call a method with the language uri in it, for example:

    http://example.com/en/mycontroller/environment/

    if you re-click on the link produce by the alt_url it will produce something like this :

    http://example.com/en/mycontrollervironment/ -> the /en have been stripped out, thats just doesnt work at all as you will expect? Could you reproduce the but @ home

    (same thing on the second link by the way : http://example.com/gl/mycontrollervironment/

    It’s clearly the url helper that broke somewhere that I can’t figure out, thanks a lot in advance, i’m struggling with that !

  • #68 / Dec 04, 2009 12:40pm

    fromjah

    5 posts

    ok thats solved, I’ve add this function to MY_Language.php from lines 30 to 39:

    function find here : http://www.webmaster-talk.com/php-forum/21334-str_replace-only-once-occurence-only.html

    function str_replace_once($needle , $replace , $haystack){ 
        // Looks for the first occurence of $needle in $haystack 
        // and replaces it with $replace. 
        $pos = strpos($haystack, $needle); 
        if ($pos === false) { 
            // Nothing found 
        return $haystack; 
        } 
        return substr_replace($haystack, $replace, $pos, strlen($needle)); 
        }


    that strip just the first occurence contain in the uri segment

    it will be called like this line 85:

    $RTR->uri->uri_string = $this->str_replace_once("/$lang_abbr", '', $RTR->uri->uri_string);

    instead of :

    $RTR->uri->uri_string = str_replace("/$lang_abbr", '', $RTR->uri->uri_string);

    Hope that helps

  • #69 / Dec 04, 2009 11:24pm

    wiredesignz

    2882 posts

    This would probably work also:

    $RTR->uri->uri_string = str_replace("/$lang_abbr/", '/', $RTR->uri->uri_string);
  • #70 / Jul 25, 2012 5:13am

    Pades

    3 posts

    I use this URI Language Identifier from WIKI. How Can I get name of controller? When $this->uri->segment(2) == id and $this->uri->segment(1) == name of the metod. Please help me.

    My routes

    $route['default_controller'] = "page";
    $route['404_override'] = '';
    $route['(\w{2})/(.*)'] = '$2';
    $route['(\w{2})'] = $route['default_controller'];
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases