• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Phil Sturgeon’s Template Library and Codeigniter Caching

#1
[eluser]Aidy[/eluser]
I'm trying to get Phil's Template Library to work with Codeigniter caching.

I thought I might be able to just output the template build as a string then load up a view with the string passed in the data array.

Code:
$this->output->cache(42000);
$data['somedata'] = 'Some Data';
$data['loader'] = $this->template->build('view', $data, TRUE);
$this->load->view('loader', $data, FALSE);

Caching does not seem to work with this approach. I've had a look at the template class and can't find anything that I think would effect the caching but some of the code there is probably a bit beyond me. Can anyone tell me why it won't work? Thanks!

#2
[eluser]seonet[/eluser]
[quote author="Aidy" date="1279830062"]I'm trying to get Phil's Template Library to work with Codeigniter caching.

I thought I might be able to just output the template build as a string then load up a view with the string passed in the data array.

Code:
$this->output->cache(42000);
$data['somedata'] = 'Some Data';
$data['loader'] = $this->template->build('view', $data, TRUE);
$this->load->view('loader', $data, FALSE);

Caching does not seem to work with this approach. I've had a look at the template class and can't find anything that I think would effect the caching but some of the code there is probably a bit beyond me. Can anyone tell me why it won't work? Thanks![/quote]

Read the Phil's code.
Code:
/**
     * Set a the cache lifetime
     *
     * @access    public
     * @param    string
     * @param    string
     * @param    boolean
     * @return    void
     */
    public function set_cache($seconds = 0)
    {
        $this->cache_lifetime = $seconds;
        return $this;
    }

#3
[eluser]InsiteFX[/eluser]
I think you will find that the Template Library is using Phil's own Caching Library!

Phil's - CodeIgniter Cache Library

InsiteFX

#4
[eluser]seonet[/eluser]
[quote author="InsiteFX" date="1301821767"]I think you will find that the Template Library is using Phil's own Caching Library!

Phil's - CodeIgniter Cache Library

InsiteFX[/quote]

I see it is using CI output cache because:
Code:
/* Line 241, 242 */
        // Let CI do the caching instead of the browser
        $this->_ci->output->cache( $this->cache_lifetime );

May be I am wrong? Big Grin

#5
[eluser]InsiteFX[/eluser]
If it has that line then yes I would say it's using ci caching!

InsiteFX

#6
[eluser]Aidy[/eluser]
Thanks a lot for the answers. At the time of writing this post (it was some months ago) I don't think the library had a set_cache method, but I figured it out and added one Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.