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.

HMVC loading URL helper problem

December 05, 2012 5:24am

Subscribe [1]
  • #1 / Dec 05, 2012 5:24am

    Altazar

    52 posts

    I’ve posted this twice in other threads a few days ago and no one answered. I’m not able to find what is causing problem. I have a fresh installation of latest CodeIgniter. The only modification I’ve done is adding HMVC and multilingual libraries.

    In modules’ controllers I have this:

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Site extends MX_Controller {
    
        public function __construct()
            {
            parent::__construct();
            }
    
        public function index(){
            $this->lang->load('site_language');
            $this->load->view('site_header');
            $this->load->view('site_content');
            $this->load->view('site_footer');
        }
    }

    In site_header view are little country flags images with links for switching languages:

    $path = 'http://mywebsite.com/images/flags';
    echo anchor($this->lang->switch_uri('de'), img($path.'/de.png'));
    echo anchor($this->lang->switch_uri('en'), img($path.'/en.png'));
    echo anchor($this->lang->switch_uri('fr'), img($path.'/fr.png'));

    Flags aren’t shown. The same code works in MVC.
    I’m autoloading URL helper and have tried loading it from the module’s controller.
    If I use HTML tags a href= and img src=, everything works fine.
    I’ve also tried creating a flags module, but it does not show flags.
    Maybe I should make a function which extends URL helper, I have no other idea.
    These are my routes:

    // URI like '/en/about' -> use controller 'about'
    $route['^de/(.+)$'] = "$1";
    $route['^en/(.+)$'] = "$1";
    $route['^fr/(.+)$'] = "$1";
     
    // URI like '/en' -> use default controller
    $route['^de$'] = $route['default_controller'];
    $route['^en$'] = $route['default_controller'];
    $route['^fr$'] = $route['default_controller'];

    Could it be causing this problem?

  • #2 / Dec 20, 2012 10:26am

    Altazar

    52 posts

    The problem is solved:
    https://github.com/EllisLab/CodeIgniter/wiki/CodeIgniter-2.1-internationalization-i18n

    /*
    in case you use it with the HMVC modular extension
    uncomment this and remove the other lines
    load the MX_Loader class
    */

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases