Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Parser Package with Caching - Cache
  • I can' t get caching to work as expected using the Fuel Parser package (https://github.com/fuel/parser). Once a page is cached it stays that way, even if the content has changed. How do I go about setting the cache_id and/or compile_id? Thanks in advance!
  • The Parser package does no caching, so you're either using one of the libraries with caching build in or you're using Fuel caching without showing how. Either way you'll need to add more description and/or code examples to get help.
  • Forgot to mention, I'm using Smarty. I've turned off Fuel's caching and set caching on for smarty in the \packages\parser\config\parser.php file. It does write the cache file to \app\cache\Smarty\ as expected. Controller: $timestamp = Date::factory()->get_timestamp();
    $view = View::forge('debug.smarty');
    $view->set('timestamp', $timestamp);
    $this->response->body = $view; View (debug.smarty): Timestamp: {$timestamp}
    Refreshing shows the same timestamp on every load. and.... $view = View::forge('debug.smarty', array($cache_id)), doesn't seem to have an impact.
  • How is smarty configured? Smarty has a development mode, in which it checks the timestamp of the source file (the view) to see if the template needs to be recompiled. If in production mode, it only compiles the template once, after that is doesn't check anymore.
  • Not in development mode. The smarty demo files work with a cache_id just fine. I don't know how to set the cache_id when using Fuel. The following page explains exactly what I'm attempting to do with Fuel: http://www.smarty.net/docsv2/en/caching.multiple.caches.tpl Thank you!!
  • I think the Smarty view in the parser package is incomplete. It calls the fetch() method, with the variables as second parameter, which is not correct. With Smarty, you'll have to use the assign() method to pass variables to a template. Could you fork the parser repo, make the changes, and send us a pull request? I'm not in a position to fix this at the moment. If you can't, add an issue at https://github.com/fuel/parser/issues.
  • I fiddled around but couldn't get the view updated without losing the data. As you mentioned, a workaround is to use "assign", and then pass the cache_id on a fetch call, so this....
    $view = View::forge('debug.smarty');
    $view->set('product_id', $product_id);
    $this->response->body = $view; becomes this...
    $view = View::forge('debug.smarty');
    $view->parser()->assign('product_id', $product_id);
    $this->response->body = $view->parser()->fetch('debug.smarty', $product_id);
    I'll add it as an issue on git, thanks!!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion