Closed rajivseelam closed 9 years ago
And I keep on getting Undefined variable: __env
whenever I try to use Runtime caching, caching in small sections.
That's because some of blade commands are compiled to Laravel's $__env
calls. For example @include is compiled to $__env->make()
call. And the @cache and other Flatten's commands generate closures, so $__env
is not accessable inside them. As for now, you can't pass variables you want to use inside that closure while using @cache command (I guess with start()
too). But you can use Flatten's section()
method and pass needed variables to closure:
<?php print Flatten::section('section-name', function() use ($__env) { ?>
Your content
<?php }); ?>
Here, I am facing another problem.
For Flatten to work I have to enable flatten in config and set it to true (which makes flatten cache all page). In that case, what is the point of using a section.
It's totally possible that I am wrong here, because I don't entirely understand how to use Flatten from documentation.
Now it is working.
Thanks.
My master layout is almost like following:
But I only want to cache whatever is generated in @yield('content') part. Why because my header includes login and logout buttons, if they are also cached, even if user is logged in, he is shown "Login".
Is it possible to cache only this part of the page keeping rest of the page dynamic?