Skip to content

Commit

Permalink
Add demo FragmentCache widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Oct 13, 2020
1 parent a1f8fd7 commit c7a6a19
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions resources/views/site/index.php
Expand Up @@ -6,10 +6,20 @@
* @var \App\ApplicationParameters $app
*/

use Yiisoft\Yii\Widgets\FragmentCache;

$this->params['breadcrumbs'] = '/';

$this->setTitle($app->get('app.name'));

$cache = FragmentCache::begin()->id('index');

?>

<h1 class="title">Hello World</h1>
<p class="subtitle">My first website with <strong>Yii 3.0</strong>!</p>
<?php if ($cache->getCachedContent() === null) : ?>
<?php $cache->start() ?>
<h1 class="title">Hello World</h1>
<p class="subtitle">My first website with <strong>Yii 3.0</strong>!</p>
<?php endif ?>

<?= FragmentCache::end() ?>

0 comments on commit c7a6a19

Please sign in to comment.