Welcome Guest, Not a member yet? Register   Sign In
Can I create a template controller?
#1

[eluser]sorenchr[/eluser]
Hi

I'm currently writing a site that uses ajax a lot. Sometimes my controllers only need to output ajax data, and this requires a lot of repeated code (formatting data, loading the same views etc.). So I'm wondering if there is a way to create a template controller that handles all this for me. Like:

Code:
<?php

class Something extends Ajax // <- the template
{

   // setup ajax data to perhaps an array

}

And the template

Code:
&lt;?php

class Ajax extends CI_Controller
{

   // do something here with the array, load views etc.

}
#2

[eluser]Joseph Wensley[/eluser]
Phil Sturgeon has a blog post about extending controllers.
http://philsturgeon.co.uk/news/2010/02/C...ing-it-DRY
#3

[eluser]sorenchr[/eluser]
[quote author="Joseph Wensley" date="1298504831"]Phil Sturgeon has a blog post about extending controllers.
http://philsturgeon.co.uk/news/2010/02/C...ing-it-DRY[/quote]

Thanks! Interesting stuff.




Theme © iAndrew 2016 - Forum software by © MyBB