[eluser]edwa5823[/eluser]
This is probably a total newb question, but I am struggling to figure out how I can get data returned from a post_controller_constructor hook. I have looked all over Google and searched the forum here to no avail.
What I am doing is dynamically loading language replacements from a MySQL database via a hook. The hook looks at the URI to determine the language and then I query the database based on the language, controller, and method that I am loading.
Everything up to that point works great and I can print the array to the screen (from within my hook). Now the big question for me is how do I get my data array back to the controller to load into the parser?
Any help here would be greatly appreciated--I am sure it is something simple that I am just overlooking.
For reference here is my hook thus far...
translator.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Translator
{
var $CI;
public function get_translation()
{
$RTR =& load_class('Router');
$class = $RTR->fetch_class();
$function = $RTR->fetch_method();
$lang = $RTR->uri->segment(1);
$CI =& get_instance();
$CI->load->database();
$sql = "
SELECT lang.id, string.text_key, string.phrase
FROM languages as lang
LEFT JOIN language_strings as string ON lang.id = string.language_id
WHERE lang.abbreviation = '{$lang}' AND string.controller = '{$class}' AND string.function = '{$function}';
";
$query = $CI->db->query($sql);
$result = $query->result();
print_r($result);
}
}
Thanks in advance,
edwa5823