瀏覽代碼

[FEATURE] Multi Template Support

this patch makes it possible to use different templates by define the template in the meta section of the *.md files. This is the first patch for multi column support.

To use an other template like index.html you can now define Template: content-sidebar which renders the template "content-sidebar.html".
Frank Nägler 11 年之前
父節點
當前提交
b0cb72272d
共有 3 個文件被更改,包括 55 次插入2 次删除
  1. 1 0
      content/index.md
  2. 4 2
      lib/pico.php
  3. 50 0
      themes/default/content-sidebar.html

+ 1 - 0
content/index.md

@@ -1,6 +1,7 @@
 /*
 Title: Welcome
 Description: This description will go in the meta description tag
+Template: content-sidebar
 */
 
 ## Welcome to Pico

+ 4 - 2
lib/pico.php

@@ -99,7 +99,8 @@ class Pico {
 			'is_front_page' => $url ? false : true,
 		);
 		$this->run_hooks('before_render', array(&$twig_vars, &$twig));
-		$output = $twig->render('index.html', $twig_vars);
+		$template = (isset($meta['template']) && strlen($meta['template']) > 0) ? $meta['template'] : 'index';
+		$output = $twig->render("{$template}.html", $twig_vars);
 		$this->run_hooks('after_render', array(&$output));
 		echo $output;
 	}
@@ -153,7 +154,8 @@ class Pico {
 			'description' 	=> 'Description',
 			'author' 		=> 'Author',
 			'date' 			=> 'Date',
-			'robots'     	=> 'Robots'
+			'robots'     	=> 'Robots',
+			'template'      => 'Template'
 		);
 
 		// Add support for custom headers by hooking into the headers array

+ 50 - 0
themes/default/content-sidebar.html

@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html lang="en" class="no-js">
+<head>
+	<meta charset="utf-8" />
+	
+	<title>{% if meta.title %}{{ meta.title }} | {% endif %}{{ site_title }}</title>
+{% if meta.description %}
+	<meta name="description" content="{{ meta.description }}"> 
+{% endif %}{% if meta.robots %}
+	<meta name="robots" content="{{ meta.robots }}">
+{% endif %}
+	
+	<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,700" type="text/css" />
+	<link rel="stylesheet" href="{{ theme_url }}/style.css" type="text/css" />
+	
+	<script src="{{ theme_url }}/scripts/modernizr-2.6.1.min.js"></script>
+</head>
+<body>
+
+	<header id="header">
+		<div class="inner clearfix">
+			<h1><a href="{{ base_url }}">{{ site_title }}</a></h1>
+			<ul class="nav">
+				{% for page in pages %}
+				<li><a href="{{ page.url }}">{{ page.title }}</a></li>
+				{% endfor %}
+			</ul>
+		</div>
+	</header>
+
+	<section id="content">
+		<div class="inner">
+            <div class="column_content">
+                {{ column_content }}
+            </div>
+            <div class="column_sidebar">
+                {{ column_sidebar }}
+            </div>
+        </div>
+	</section>
+	
+	<footer id="footer">
+		<div class="inner">
+			<a href="http://pico.dev7studios.com">Pico</a> was made by <a href="http://gilbert.pellegrom.me">Gilbert Pellegrom</a> 
+			from <a href="http://dev7studios.com">Dev7studios</a>.
+		</div>
+	</footer>
+    
+</body>
+</html>