Welcome Guest, Not a member yet? Register   Sign In
Retrieving data before loading template
#1

[eluser]Y0shi[/eluser]
Hello,

I've been working with CodeIgniter since a while now and wrote my whole cms for personal purposes in CI. I'm really fascinated how much fun programming can be.

Now I've come to a point where I don't really know where to put something in. My problem is:

I'm working with the template engine from williams concepts - guess most of you know this thing. I got a default content area where all controllers send their output to. But I also got some areas around this area. Like latest news or stuff like that. So, if I dont want to put some lines on top of every controller, what can I do to load all this data make it ready for output before loading a controller?

I hope you understand my problem Smile

Thanks for your help in advance.
Regards
#2

[eluser]Y0shi[/eluser]
nobody got an idea?
#3

[eluser]Colin Williams[/eluser]
Use your own base controller

Code:
class MY_Controller extends Controller {

  function MY_Controller()
  {
    parent::Controller();
    $this->load->model('blocks');
    $blocks = $this->blocks->get_page_blocks();
    foreach ($blocks as $block)
    {
      $this->template->write($block['region'], $block['content']);
    }
  }

}

Then your controllers extend MY_Controller, and the MY_Controller constructor is called.




Theme © iAndrew 2016 - Forum software by © MyBB