I only have one page that is cached and has dynamic data on it.  It
was really messy with Smarty and there are some other features I
wanted so I have decided to clean it all up.  See 
http://www.lloydhome.com/news/view/5
for a full explaination.  AS A BONUS, you get the controller's
beforeFilter() to run before showing cached content - just be careful
with what you do.  It should be used to authenticate that the cache is
available to the user.

The short answer for those searching in the future: You have to set
the $this->_tpl_vars array to the variables you want accessed.  This
can only be set if it is empty (cached case).  This is a hoop to go
through but the alternative is usually a worse set of {php} global
$foo; ....{/php} .

HTH,

David Lloyd
--
lloydhome consulting, inc.
http://lloydhome.com


On Feb 14, 8:56 am, "lloydhome" <[EMAIL PROTECTED]> wrote:
> As this is using Cake's cache the SAME limitations are applied.
>
> How is it that 'time' will be set in the view if the controllers are
> not run?  When it is cached NO CONTROLLERS are run.  NO SMARTY is
> run.  Only the session variables are available.
>
> I see in my template it is difficult to get a clean code except in my
> situation so I will change the SmartyView to have easier caching.  But
> you still will have to rethink how your variables are accessed.
>
> I'll reply back soon,
>
> David Lloyd
> --
> lloydhome consultinghttp://lloydhome.com
>
> On Feb 14, 7:48 am, "rollenc" <[EMAIL PROTECTED]> wrote:
>
> > I am puzzle.
> > I put the <cake:nocache> Tag to layout/index.php And it no use too.
> > And now, the code
> >   <cake:nocache>
> >   {#$time#}
> >   </cake:nocache>
> >  in /view/index.tpl is parsed as follow in cache file:
> > <?php echo $this->_tpl_vars['time']; ?>
>
> > The value $this->_tpl_vars['time'] is not exist since the smarty
> > complie not run(cache runed).
>
> > Can I get a demo?
> > Tanks.
>
> > On 2月10日, 下午9时52分, "lloydhome" <[EMAIL PROTECTED]> wrote:
>
> > > Quote from previous:
>
> > >    If you use <cake:nocache> it should work as long as the tag is in
> > > the layout file.
>
> > > That means it is not working in the included views - like yours.  It
> > > would not work anyway with your case as no controller would run to set
> > > $time.  The dynamic part must come from session or other outside
> > > means.
>
> > > HTH,
>
> > > David Lloyd
> > > --
> > > lloydhome consultinghttp://lloydhome.com
>
> > > On Feb 9, 10:57 pm, "rollenc" <[EMAIL PROTECTED]> wrote:
>
> > > > Thx, But I am puzzle in  part cache.
> > > > I type this code:
> > > > controler:
> > > >     var $view = 'Smarty';
> > > >     var $helpers = array('Cache');
> > > >     var $cacheAction = array('index' => 86400, 'view/' => 3600);
> > > >     function index()
> > > >         {
> > > >                 $this->set('posts', $this->Test->findAll());
> > > >                 $this->set('time', date('H:i:s', time()));
> > > >         }
> > > > In View
> > > >         {#foreach from=$posts item=post#}
> > > >         <h1>{#$post.Test.title#}</h1>
> > > >         <p>{#$post.Test.body#}</p>
> > > >         <hr>
> > > >         {#foreachelse#}
> > > >         There is nothing
> > > >         {#/foreach#}
>
> > > >         <cake:nocache>
> > > >         {#$time#}
> > > >         </cake:nocache>
>
> > > >         Website: {#$smarty.server.SERVER_NAME#}
>
> > > > Full page is cached. but nocache tag is ommited.
> > > > And the cache file as this:
> > > >   <cake:nocache>
> > > >   03:46:08
> > > >   </cake:nocache>
>
> > > > These is no parse.And the cache is no useful.
>
> > > > What is correct?
>
> > > > On 2月10日, 上午3时12分, "lloydhome" <[EMAIL PROTECTED]> wrote:
>
> > > > > I have a SmartyView that handles caching by utilizing cake's page
> > > > > caching.  It handles full-page caching great.  If you use
> > > > > <cake:nocache> it should work as long as the tag is in the layout
> > > > > file.  I have need for a cachable, non-static ajax call with no layout
> > > > > and this solution nor cake's default works for me.  So I have an idea
> > > > > for that too but you'll need to be patient.
>
> > > > > The file is athttp://www.lloydhome.com/files/smarty.ph_.txtandneeds
> > > > > to be renamed and placed in your /app/views directory.
>
> > > > > To use in your controller:
>
> > > > >         var $view = 'Smarty';
> > > > >         var $cacheAction = 300;  // 5 minutes
> > > > >         var $helpers = array('Cache');
>
> > > > > HTH,
>
> > > > > David Lloyd
> > > > > --
> > > > > lloydhome consultinghttp://lloydhome.com
>
> > > > > On Feb 9, 8:42 am, "lloydhome" <[EMAIL PROTECTED]> wrote:
>
> > > > > > I also use Smarty but since it is a View and not recognized by the
> > > > > > core it is not advantageous to use its caching.  I would argue that
> > > > > > this it actually better to not try without good reason.  The problem
> > > > > > with this approach is the logic still occurs in the controller ad 
> > > > > > the
> > > > > > only time savings is in rendering the view.
>
> > > > > > The SmartyView doesn't cache the output the way cake wants it but I
> > > > > > have some ideas on that I am going to try...  It will be easy to 
> > > > > > setup
> > > > > > whole page caching but using <cake:nocache> will be harder.  I'll 
> > > > > > post
> > > > > > back with what I find.
>
> > > > > > David Lloyd
> > > > > > --
> > > > > > lloydhome consultinghttp://www.lloydhome.com
>
> > > > > > On Feb 9, 4:39 am, "rollenc" <[EMAIL PROTECTED]> wrote:
>
> > > > > > > I combine smarty & cackephp followng this article: http://
> > > > > > > projects.simpleteq.com/CakePHP/smarty.html
> > > > > > > but I don't know how to use smarty cache .
> > > > > > > Call for help. Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to