EllisLab text mark
Advanced Search
1 of 2
1
   
Poll
Do you think this is a good idea?
Yes 43
No 4
Total Votes: 47
You must be a logged-in member to vote
Sparks : Caching Template system
Posted: 26 July 2007 11:39 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2006-08-06
918 posts

Thanks Al! That was easy. grin

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

 
Posted: 26 July 2007 12:17 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2006-10-24
57 posts

Another thing I just discovered. You can’t use $this for loading helpers and doing validation checks, however, $CI works as you’re setting it using get_instance()

Is there any way to get $this working inside the templates again?

 
Posted: 26 July 2007 12:21 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Joined: 2007-07-14
26 posts

@jbowman

Yes, thats a problem at the moment. I will fix it in the next version, or at the very least upload a new fix for this tonight (GMT time). Hope thats ok!

 
Posted: 26 July 2007 12:35 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Joined: 2006-10-24
57 posts

perfectly fine, this is spare time stuff for all of us, so the rapid response is appreciated smile

 
Posted: 26 July 2007 06:04 PM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2007-07-14
26 posts

Sparks 1.1 is now available here: Sparks.v1.1.zip.

Changes:

* Fixed used of $this inside view files. ($CI still works as well).
* Integrated into CI Loader class better.
* New feature You can now pass data arrays into the sparks_include function via an optional second argument. I.e.

<h2>Recent news</h2>

<? sparks_include('newslist.php', array('news' => $recent_news)); ?>

<h2>Popular news</h2>

<? sparks_include('newslist.php', array('news' => $popular_news)); ?> 

This allows you to reuse ‘parts’ over and over again with separate data. Note that the supplied data are merged into the global variables, i.e. all the global variables are available in the sub-part, but also the variables you pass in!

* For PHP 4 users:

//Instead of:

$this->sparks->id($id);
$this->sparks->group($group);
$this->sparks->ttl($ttl);

//Can be replaced by:

$this->sparks->initialize($id$group$ttl);

//Less typing for php4 users! 

Ok, it should be a drop in replacement. I have not had time to test this extensively. Please let me know if you find a problem.

I am planning v2.0 which will be quite different (internally)... Any suggestions?

 
Posted: 26 July 2007 10:39 PM   [ Ignore ]   [ # 16 ]   [ Rating: 0 ]
Joined: 2006-10-24
57 posts

Looks good, I put my loop for creating the language variable back into my copy. For now I just have it in the display function. I figure, I shouldn’t be caching those anyway, good way to remind me and keep my synatax right.

 
Posted: 27 July 2007 04:19 AM   [ Ignore ]   [ # 17 ]   [ Rating: 0 ]
Joined: 2007-07-14
26 posts

@jbowman

I will probably include your language stuff in version 2… Sorry I forgot last night for 1.1!

Theres two ways to think of it. One is the languages should not be cached (your approach), the other is to cache separate files depending on the language. But thats a silly idea (could lead to cache discrepancies between the languages). I cant see the overhead for dynamically including languages being that large…

Thanks for your suggestion!

Instead of looping over all the keys in the language I think it may be more efficient to do this:

$lang $this->CI->lang->language

Should work the same I think!

Also, does the language import bit need to be in the store() method as they are never cached?

 
Posted: 27 July 2007 08:26 AM   [ Ignore ]   [ # 18 ]   [ Rating: 0 ]
Joined: 2006-10-24
57 posts

I’m still not doing it in the store, though I haven’t gone multi-lingual with my site either yet. Someone would want to do testing with a site that has at least two languages running to test failure modes.

And wow.. I really should have printed out that CI object, you’re right, I was wasting time with that loop. One tweak, I’d pass it as a reference

$lang =& $this->CI->lang->language
 
Posted: 27 July 2007 10:10 AM   [ Ignore ]   [ # 19 ]   [ Rating: 0 ]
Avatar
Joined: 2006-05-29
277 posts

Uaooooohhhh! very great work…. thank you… ciao

 Signature 

CI Js_calendar plugin click

WYSIWYG with CI

 
Posted: 02 August 2007 10:15 AM   [ Ignore ]   [ # 20 ]   [ Rating: 0 ]
Joined: 2006-12-27
16 posts

Very useful initiative.
The caching system in CI is one of its weakest points.
This Sparks thing sounds a great and much needed library

Maybe you could integrate code from my automatic
cache cleaning class
to support automatic cache cleaning..

 
Posted: 13 August 2007 03:53 PM   [ Ignore ]   [ # 21 ]   [ Rating: 0 ]
Avatar
Joined: 2006-12-20
88 posts

Is this library usable with the parser? I guess I don’t really understand why you would choose to preg_match for <$?= ... in the view.

What I am trying to accomplish is just caching an entire view (or part) and possibly some variables inside of a view.

I’m confused on how to accomplish this… Any pointers would be great?

 
Posted: 24 September 2007 08:32 AM   [ Ignore ]   [ # 22 ]   [ Rating: 0 ]
Joined: 2006-06-05
54 posts

Any progress on Sparks?
I’m very interested!

 
Posted: 24 September 2007 04:35 PM   [ Ignore ]   [ # 23 ]   [ Rating: 0 ]
Joined: 2007-07-14
26 posts

Afraid not. I have decided that Code Igniter does not meet my needs and therefore moving towards a Zend Framework based system. Sparks caching lives on but in a Zend based version! Sorry! Feel free to take the code and run with it!

 
1 of 2
1