Using a library within a view

Hello all

Is it possible to load and use a library within a view.
I have a class which has a number of functions that do common tasks, such as building a select tag from an array.

If I load the library in the view with $this->load->library('htmllib') I don't get any error, but as soon as I reference the class with $this->htmllib->test() I get Undefined property: CI_Loader::$htmllib.

If I load the library within the controller and try to call of the functions all is ok, however as the purpose of the class is to deal with rendering html elements (in this case a select) I would like to keep this in the view.

Thanks in advance for any info / advise on this.


I pass some libraries into the view by reference, you could try that.

[eluser]Colin Williams[/eluser]
I do what kurucu does when necessary

$data['pagination'] =& $this->pagination;
$this->load->view('results', $data);

In view:

<div>&lt;?php print $pagination->create_links() ?&gt;</div>

[quote author="Colin Williams" date="1254271933"]I do what kurucu does when necessary

$data['pagination'] =& $this->pagination;
$this->load->view('results', $data);

In view:

<div>&lt;?php print $pagination->create_links() ?&gt;</div>

Hmmm will this work with modules? I assume it should...

i use (ahem! sorry William), Phil's Template Library, only cuz it works seemlessly with HMVC and the updated MS/ME combined platform, etc, yadda yadda... but it should work irregardless of the templating system used....

tossing the =& reference of the object is quite ingenious... as this isn't discussed in a lot of places.

i'm just hoping it'll work on CI2.0+ME/MS5.3+, etc...

that's the ult. question.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.