Skip to content

Instantly share code, notes, and snippets.

@sofadesign
Created August 5, 2009 13:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sofadesign/162680 to your computer and use it in GitHub Desktop.
Save sofadesign/162680 to your computer and use it in GitHub Desktop.
<?php
// LIMONADE FLASH FEATURES EXAMPLES
require_once 'lib/limonade.php';
function configure()
{
option('env', ENV_DEVELOPMENT);
}
function before()
{
layout('html_default_layout');
}
dispatch('/', 'index');
function index()
{
// those flashs will be avilable on next page
flash('notice', 'Will be displayed on page two');
flash('errors', 'first error message', 'second error message', 'third error message');
set('page_title', 'Index Page');
set('next', '/two');
return html('<p>Hellooo!</p>');
}
dispatch('/two', 'index_two');
function index_two()
{
flash('notice', 'Will be displayed on page three');
set('page_title', 'Page Two');
set('next', '/three');
return html('<p>Hellooo!</p>');
}
dispatch('/three', 'index_three');
function index_three()
{
set('page_title', 'Page three');
set('next', '/');
return html('<p>click to next to go back to first page. There will be no flash message</p>');
}
dispatch('/reset', 'index_reset');
function index_reset()
{
set('page_title', 'Page reset');
set('next', '/');
return html('<p>click to next to go back to first page. There will be no flash message</p>');
}
run();
# ___ HTML ____
function html_default_layout($vars){ extract($vars);?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flash features example</title>
<link rel="stylesheet" href="<?=url_for('/_lim_css/screen.css')?>" type="text/css" media="screen">
</head>
<body>
<div id="header">
<h1>Limonade</h1>
</div>
<div id="content">
<div id="main">
<h1>Page: <?=h($page_title)?></h1>
<?=$content;?>
<section>
<h4>Current flash messages ($flash)</h4>
<pre><code>
<?= var_dump($flash); ?>
</code></pre>
<h4>Current flash messages (flash_now())</h4>
<pre><code>
<?= var_dump(flash_now()); ?>
</code></pre>
<h4>Flash messages that will be displayed on next page(flash())</h4>
<pre><code>
<?= var_dump(flash()); ?>
</code></pre>
</section>
</div>
<hr>
<nav>
<p><strong>Menu:</strong>
<a href="<?=url_for('/reset')?>">Reset all flashs and goto index</a>
<? if($next): ?>| <a href="<?=url_for($next)?>">Next page</a><? endif;?>
</p>
</nav>
<hr>
</div>
</body>
</html>
<?};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment