[FEATURE] multiple column support
This commit is contained in:
parent
a3f5b70d1b
commit
ecd57ee083
4 changed files with 50 additions and 2 deletions
|
@ -1,9 +1,19 @@
|
|||
/*
|
||||
Title: Error 404
|
||||
Robots: noindex,nofollow
|
||||
Template: content-sidebar
|
||||
*/
|
||||
|
||||
|
||||
{column:content}
|
||||
|
||||
Error 404
|
||||
=========
|
||||
|
||||
Woops. Looks like this page doesn't exist.
|
||||
Woops. Looks like this page doesn't exist.
|
||||
|
||||
{/column:content}
|
||||
|
||||
{column:sidebar}
|
||||
<div class="big">404</div>
|
||||
{/column:sidebar}
|
|
@ -3,6 +3,7 @@ Title: Welcome
|
|||
Description: This description will go in the meta description tag
|
||||
*/
|
||||
|
||||
|
||||
## Welcome to Pico
|
||||
|
||||
Congratulations, you have successfully installed [Pico](http://pico.dev7studios.com). Pico is a stupidly simple, blazing fast, flat file CMS.
|
||||
|
@ -73,6 +74,7 @@ All themes must include an `index.html` file to define the HTML structure of the
|
|||
* `{{ meta.date_formatted }}`
|
||||
* `{{ meta.robots }}`
|
||||
* `{{ content }}` - The content of the current page (after it has been processed through Markdown)
|
||||
* `{{ column_<name> }}` - The column name of the content of the current page (after it has been processed through Markdown) [more information](#columns)
|
||||
* `{{ pages }}` - A collection of all the content in your site
|
||||
* `{{ page.title }}`
|
||||
* `{{ page.url }}`
|
||||
|
@ -94,6 +96,15 @@ Pages can be used like:
|
|||
{% endfor %}
|
||||
</ul></pre>
|
||||
|
||||
### <a name="columns"></a> Columns
|
||||
|
||||
You can use multiple columns within the templates. A good example is the 404 error page. The basic logic is very simple. In the template you can use twig variables like `{{ column_content }}`.
|
||||
To define which content should be displayed in which column, you have to wrap the content (in the *.md files) with markers like this:
|
||||
|
||||
<pre>{column:content}
|
||||
my content for column content
|
||||
{/column:content}</pre>
|
||||
|
||||
### Plugins
|
||||
|
||||
See [http://pico.dev7studios.com/plugins](http://pico.dev7studios.com/plugins)
|
||||
|
|
16
lib/pico.php
16
lib/pico.php
|
@ -11,6 +11,7 @@ use \Michelf\MarkdownExtra;
|
|||
*/
|
||||
class Pico {
|
||||
|
||||
protected $columns = array();
|
||||
private $plugins;
|
||||
|
||||
/**
|
||||
|
@ -101,7 +102,9 @@ class Pico {
|
|||
'next_page' => $next_page,
|
||||
'is_front_page' => $url ? false : true,
|
||||
);
|
||||
|
||||
foreach ($this->columns as $var => $code) {
|
||||
$twig_vars["column_{$var}"] = $code;
|
||||
}
|
||||
$template = (isset($meta['template']) && $meta['template']) ? $meta['template'] : 'index';
|
||||
$this->run_hooks('before_render', array(&$twig_vars, &$twig, &$template));
|
||||
$output = $twig->render($template .'.html', $twig_vars);
|
||||
|
@ -138,6 +141,17 @@ class Pico {
|
|||
{
|
||||
$content = preg_replace('#/\*.+?\*/#s', '', $content); // Remove comments and meta
|
||||
$content = str_replace('%base_url%', $this->base_url(), $content);
|
||||
|
||||
// pattern to find {column:xyz} {/column:xyz} column marker
|
||||
$pattern = '#({column:(.*?)})(.+?)({/column:\\2})#ims';
|
||||
preg_match_all($pattern, $content, $matches);
|
||||
|
||||
$counter = 0;
|
||||
foreach ($matches[2] as $var) {
|
||||
$this->columns[$var] = MarkdownExtra::defaultTransform($matches[3][$counter]);
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$content = MarkdownExtra::defaultTransform($content);
|
||||
|
||||
return $content;
|
||||
|
|
|
@ -240,6 +240,19 @@ blockquote {
|
|||
#footer a { color: #ddd; }
|
||||
#footer a:hover { color: #fff; }
|
||||
|
||||
.col_sidebar {
|
||||
float: left;
|
||||
width: 200px;
|
||||
background: #C0C0C0;
|
||||
margin: 0 10px 10px 0;
|
||||
}
|
||||
.col_sidebar .big {
|
||||
font-size: 121px;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
margin-left: -3px;
|
||||
line-height: 79px;
|
||||
}
|
||||
/* Misc Styles
|
||||
/*---------------------------------------------*/
|
||||
.clearfix:before,
|
||||
|
|
Loading…
Add table
Reference in a new issue