Template library of Colin Williams not working [Solved] |
[eluser]ajitabhpandey[/eluser]
Hi, I have recently started using CodeIgnitor for few of my projects. I am using the template library version 1.4.1 from Colin Williams (http://www.williamsconcepts.com/ci/codei.../template/). After following the instruction to place the files in application/config, application/library and application/view, I made the following change in index function of "welcome" controller which comes with the default code ignitor code. Code: function index() When I visit the URL http://localhost, this is what I get: Quote:A PHP Error was encountered Any hints as to what am I doing wrong.
[eluser]theprodigy[/eluser]
do you have template.php in your config folder, and does it contain the necessary $template array as specified in http://www.williamsconcepts.com/ci/codei...rence.html?
[eluser]ajitabhpandey[/eluser]
Yes I have the following line: Code: $template['default']['template'] = 'template'; I have tried adding a php extension as follows, but it did not work as well. Code: $template['default']['template'] = 'template.php';
[eluser]steelaz[/eluser]
Looks like Template library is not loaded, try adding this line before using $this->template Code: $this->load->library('template');
[eluser]ajitabhpandey[/eluser]
Yep, works like a charm. I thought any libraries put in applications/libraries folder should be loaded automatically. At-least that's what happening in one of the other projects where a custom php file in application/libraries directory is being auto-loaded. Thanks for pointing that out.
[eluser]steelaz[/eluser]
Most of the time you don't need to use all libraries in a single controller, so I think it's better to load them when you need them. For libraries that you use in most controllers, such as Template, you can auto-load them by editing /application/config/autoload.php |
Welcome Guest, Not a member yet? Register Sign In |