[eluser]Otemu[/eluser]
Definitely the best way is to create a library(custom class)
Use $this->CI =& get_instance(); so you have access to other classes
Then to load database use $CI->load->database();
to run queries use $this->CI->db->query()
Should be no problem for you to call something like this within your class structure
$this->template->mytemplate(5,$data,‘content-view’)
Your have a function like this
Code:
function mytemplate($myNum, $data, $myView)
{
//your code
}
Look at how Codeigniter writes there core libraries for tips
Hope that helps