6

I'm trying to use Phil Sturgeon's CodeIgniter Template library, but I can't get it to change my pages. I read the documentation, followed the steps there,

  1. Download
  2. Copy to application folder
  3. Create a views/layouts/default view
  4. (Auto)load the library

however, it is not clear as to how the template is actually implemented. I thought that loading the view would apply the template everywhere, but it doesn't seem to work that way. I've also read about it in the CodeIgniter Wiki, but it looked too complicated to be the right answer.

How are you supposed to use Phil Sturgeon's Template with your controllers? (or views?) Am I missing something here?

Jonathan Allard
  • 18,429
  • 11
  • 54
  • 75

1 Answers1

10

It does not overload the load->view() methods, that would be bad. You need to update your controllers to use the template's syntax and methods in every instance you want to use it:

http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/

You will use $this->template->build() instead of $this->load->view() in most cases, after constructing your template by defining regions, setting titles, etc.

There should have been a user guide included in your download with examples.

Wesley Murch
  • 101,186
  • 37
  • 194
  • 228
  • This is helpful. This was really not clear from the docs or anywhere. Hopefully it'll help other people. But the thing is, I've replaced `load->view('view_name',$data)` with `template->build('view_name',$data)`, but I still see no layout. Did I miss something else? – Jonathan Allard Apr 27 '11 at 23:53
  • 1
    Apparently, the default config options do not make the library work out of the box. You have to change the `$config['layout']` paramater to `default` (or your default template name) in `config/template.php` for it to wrap around. – Jonathan Allard Apr 28 '11 at 00:07
  • 2
    Does anyone know why the user_guide is down? http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/ . Is it no longer supported? It seems like this is the go-to for CI templating but there are others. – Ryan Ore Apr 10 '13 at 22:14