[FEATURE] add multi column support
with this commit the core support multi column layouts. this is possible by using {column:xyz} and {/column:xyz} in *.md files and new dynamic twig variables like {{ column_xyz }}. There no restrictions, its possible to use unlimited columns.
This commit is contained in:
parent
f16e1f9ebe
commit
4b519a7cf3
3 changed files with 37 additions and 4 deletions
|
@ -3,6 +3,9 @@ Title: Welcome
|
|||
Description: This description will go in the meta description tag
|
||||
*/
|
||||
|
||||
|
||||
{column:content}
|
||||
|
||||
## Welcome to Pico
|
||||
|
||||
Congratulations, you have successfully installed [Pico](http://pico.dev7studios.com). Pico is a stupidly simple, blazing fast, flat file CMS.
|
||||
|
@ -10,9 +13,9 @@ Congratulations, you have successfully installed [Pico](http://pico.dev7studios.
|
|||
### Creating Content
|
||||
|
||||
Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create `.md` files in the "content"
|
||||
folder and that becomes a page. For example, this file is called `index.md` and is shown as the main landing page.
|
||||
folder and that becomes a page. For example, this file is called `index.md` and is shown as the main landing page.
|
||||
|
||||
If you create a folder within the content folder (e.g. `content/sub`) and put an `index.md` inside it, you can access that folder at the URL
|
||||
If you create a folder within the content folder (e.g. `content/sub`) and put an `index.md` inside it, you can access that folder at the URL
|
||||
`http://yousite.com/sub`. If you want another page within the sub folder, simply create a text file with the corresponding name (e.g. `content/sub/page.md`)
|
||||
and you will be able to access it from the URL `http://yousite.com/sub/page`. Below we've shown some examples of content locations and their corresponing URL's:
|
||||
|
||||
|
@ -106,3 +109,9 @@ lists all of the settings and their defaults. To override a setting, simply unco
|
|||
### Documentation
|
||||
|
||||
For more help have a look at the Pico documentation at [http://pico.dev7studios.com/docs](http://pico.dev7studios.com/docs)
|
||||
|
||||
{/column:content}
|
||||
|
||||
{column:sidebar}
|
||||
sidebar content goes here
|
||||
{/column:sidebar}
|
||||
|
|
15
lib/pico.php
15
lib/pico.php
|
@ -11,6 +11,7 @@ use \Michelf\MarkdownExtra;
|
|||
*/
|
||||
class Pico {
|
||||
|
||||
private $columns = array();
|
||||
private $plugins;
|
||||
|
||||
/**
|
||||
|
@ -98,6 +99,9 @@ class Pico {
|
|||
'next_page' => $next_page,
|
||||
'is_front_page' => $url ? false : true,
|
||||
);
|
||||
foreach ($this->columns as $var => $code) {
|
||||
$twig_vars["column_{$var}"] = $code;
|
||||
}
|
||||
$this->run_hooks('before_render', array(&$twig_vars, &$twig));
|
||||
$output = $twig->render('index.html', $twig_vars);
|
||||
$this->run_hooks('after_render', array(&$output));
|
||||
|
@ -133,6 +137,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;
|
||||
|
|
|
@ -29,9 +29,18 @@
|
|||
</header>
|
||||
|
||||
<section id="content">
|
||||
<div class="inner">
|
||||
<!-- old {{ content }} variable works also -->
|
||||
<!-- div class="inner">
|
||||
{{ content }}
|
||||
</div>
|
||||
</div -->
|
||||
<div class="inner">
|
||||
<div class="col_content">
|
||||
{{ column_content }}
|
||||
</div>
|
||||
<div class="col_sidebar">
|
||||
{{ column_sidebar }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer id="footer">
|
||||
|
|
Loading…
Add table
Reference in a new issue