Welcome Guest, Not a member yet? Register   Sign In
Nested views and caching
#1

[eluser]sidscorner[/eluser]
Hi there,

I have a question about nested views and caching.

Initially I had a function in my controller that generates a dynamic page and I was passing data into it. I then separated the function into two, because I wanted to cache a chunk of the data. The code is something like this:

Code:
function foo() {
  $data['dynamic'] = $this->some_model->get_dynamic_data();
  $data['static'] = $this->_bar();
  $this->load->view('main_page',$data);
}

function _bar() {
  $data['chunk'] = $this->some_model->get_chunk_of_data();
  $this->output->cache(1440);
  return $this->load->view('chunk',$data,TRUE);
}

My expectation was that the main page would still be dynamic while it pulled the 'chunk' from the cache. However, the above code caches the entire 'main_page' view.

What am I doing wrong? Would appreciate some help. Thanks in advance!

Cheers
#2

[eluser]sidscorner[/eluser]
Any suggestions anyone?

Cheers
#3

[eluser]sidscorner[/eluser]
Hi, thanks for the tip.

The template library looks great but seems too complex for my current needs.

Just wondering if anyone knows a quick workaround.

cheers.
#4

[eluser]sidscorner[/eluser]
Never mind, found a suitable solution:

http://ellislab.com/forums/viewthread/102659/




Theme © iAndrew 2016 - Forum software by © MyBB