override FUEL libraries

edited November 2014 in Modules
Is there a way to create a library that inherits from a FUEL library? For instance, I'm running FUEL 1.0 and am trying to implement the language functionality but noticed that the FUEL language library is only working in the "auto" mode -- query string is being ignored for some reason -- and it's grabbing the default option and not even looking at the User Agent or Cookie values in the detect() function. Basically, I was thinking I could inherit the Fuel_language.php file and modify the detect functionality. Is that even possible?

Comments

  • edited 3:27AM
    There isn't a way like in CI where you can create a MY_Fuel_language.php file and it will overwrite it it at this time. You could however, extend the class and just instantiate it with something like the following:
    $this->load->library('MY_fuel_language', array(), 'fuel_langauge');
    The Fuel_language class actually gets loaded on the $CI object as $CI->fuel_language. $CI->fuel->language is just an alias so the above would essentially overwrite it.

    To better address your probably, have you update to the latest version and/or looked at all the configuration parameters you can overwitein your fuel/application/config/MY_fuel.php file:
    // Languages for pages. The key is saved to the page variables $config['languages'] = array( 'english' => 'English' ); // Specifies the method in which to look for pages with different languages. // Values can be "domain", "segment", "query_string" or "both" (which means both "segment" and "query_string") $config['language_mode'] = 'domain'; // Append the current language value to the site URL automatically $config['add_language_to_site_url'] = FALSE; // force the default language segment, or query string on any URLs created with site_url $config['language_force_default_to_site_url'] = FALSE; // The name of the query string parameter to use for setting the language $config['language_query_str_param'] = 'lang'; // The name of the cookie to hold the currently selected language. One will be generated if left blank $config['language_cookie_name'] = ''; // Default is 2 years $config['language_cookie_exp'] = '63072000'; // Use cookies to remember a selected language $config['language_use_cookies'] = TRUE; // Will check the user agent during language detection $config['language_detect_user_agent'] = ''; // The default language to use $config['language_default_option'] = NULL;
  • edited 3:27AM
    I have played around with the config settings but what I'm finding is in fuel_language.php in the detect function since I have the mode set to 'both' when it gets to check the segment if there is no language set it takes the default; essentially blocking/skipping the logic for checking the cookie or user agent. If I try changing the mode to query_string it doesn't properly detect the lang parameter in the query string.

    For your suggestion on creating an extended library, where would you suggest I put that load call?
  • edited 3:27AM
    The easiest place to put the code would be in the fuel/application/views/_variables/global.php
Sign In or Register to comment.