diff --git a/docs.html b/docs.html index 3bd1728..660b30d 100644 --- a/docs.html +++ b/docs.html @@ -8,289 +8,18 @@ nav: 2
- Pico is a flat file CMS, this means there is no administration backend and database to deal with.
+ Pico is a flat file CMS, this means there is no administration backend or database to deal with.
You simply create .md files in the "content" folder and that becomes a page.
- To run Pico you simply need PHP 5.3+ to be running on your server.
- If you're running Apache you will require mod_rewrite
to be enabled.
-
- $ curl -sS https://getcomposer.org/installer | php
- $ php composer.phar install
-
-
-
- $ php -S 0.0.0.0:8080 ./
-
-
- .htaccess
file if required.You can override the default Pico settings (and add your own custom settings) by editing config/config.php
in the Pico directory. The config/config.php.template
lists all of the settings and their defaults. To override a setting simply copy config/config.php.template
to config/config.php
, uncomment the setting and set your custom value.
- 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-sample" folder and that becomes a page.
-
- If you created folder within the content-sample folder (e.g. content-sample/sub
) and put an index.md
inside it, you can access that folder at the URL
- http://yoursite.com/sub
. If you want another page within the sub folder, simply create a text file with the corresponding name (e.g. content-sample/sub/page.md
)
- and will be able to access it from the URL http://yoursite.com/sub/page
.
-
Below we've shown some examples of content locations and their corresponing URL's:
-Physical Location | -URL | -
---|---|
content-sample/index.md | -/ | -
content-sample/sub.md | -/sub | -
content-sample/sub/index.md | -/sub (same as above) | -
content-sample/sub/page.md | -/sub/page | -
content-sample/a/very/long/url.md | -/a/very/long/url | -
If a file cannot be found, the file content-sample/404.md
will be shown.
- Text files are marked up using Markdown. - They can also contain regular HTML. At the top of text files you can place a block comment and specify certain attributes of the page. - For example: -
-
- /*
- Title: Welcome
- Description: This description will go in the meta description tag
- Author: Joe Bloggs
- Date: 2013/01/01
- Robots: noindex,nofollow
- Template: index (allows you to use different templates in your theme)
- */
-
-
- These values will be contained in the {% raw %}{{ meta }}{% endraw %}
variable in themes (see below).
- There are also certain variables that you can use in your text files:
-
- You can create themes for your Pico installation and in the "themes" folder. Check out the default theme for an example of a theme. Pico uses
- Twig for it's templating engine. You can select your theme by setting the $config['theme']
variable
- in config/config.php
to your theme folder.
-
All themes must include an index.html
file to define the HTML structure of the theme. Below are the Twig variables that are available to use in your theme:
{% raw %}{{ config }}{% endraw %}
- Conatins the values you set in config/config.php
(e.g. {% raw %}{{ config.theme }}{% endraw %}
= "default"){% raw %}{{ base_dir }}{% endraw %}
- The path to your Pico root directory{% raw %}{{ base_url }}{% endraw %}
- The URL to your Pico site{% raw %}{{ theme_dir }}{% endraw %}
- The path to the Pico active theme direcotry{% raw %}{{ theme_url }}{% endraw %}
- The URL to the Pico active theme direcotry{% raw %}{{ site_title }}{% endraw %}
- Shortcut to the site title (defined in config/config.php
){% raw %}{{ meta }}{% endraw %}
- Contains the meta values from the current page
- {% raw %}{{ meta.title }}{% endraw %}
{% raw %}{{ meta.description }}{% endraw %}
{% raw %}{{ meta.author }}{% endraw %}
{% raw %}{{ meta.date }}{% endraw %}
{% raw %}{{ meta.date_formatted }}{% endraw %}
{% raw %}{{ meta.robots }}{% endraw %}
{% raw %}{{ content }}{% endraw %}
- The content of the current page (after it has been processed through Markdown){% raw %}{{ pages }}{% endraw %}
- A collection of all the content in your site
- {% raw %}{{ page.title }}{% endraw %}
{% raw %}{{ page.url }}{% endraw %}
{% raw %}{{ page.author }}{% endraw %}
{% raw %}{{ page.date }}{% endraw %}
{% raw %}{{ page.date_formatted }}{% endraw %}
{% raw %}{{ page.content }}{% endraw %}
{% raw %}{{ page.excerpt }}{% endraw %}
{% raw %}{{ prev_page }}{% endraw %}
- A page object of the previous page (relative to current_page){% raw %}{{ current_page }}{% endraw %}
- A page object of the current_page{% raw %}{{ next_page }}{% endraw %}
- A page object of the next page (relative to current_page){% raw %}{{ is_front_page }}{% endraw %}
- A boolean flag for the front pagePages can be used like:
-{% raw %}<ul class="nav"> - {% for page in pages %} - <li><a href="{{ page.url }}">{{ page.title }}</a></li> + {% for doc in site.docs %} + + {{ doc.output }} {% endfor %} - </ul>{% endraw %}- -
If you would like to add a blog to your Pico site we suggest taking the following steps:
-{% raw %}{% if is_front_page %} <!-- Front page lists all blog posts --> - - <div id="posts"> - {% for page in pages %} - {% if page.date %} <!-- Note we check for Date field (posts) here --> - <div class="post"> - <h3><a href="{{ page.url }}">{{ page.title }}</a></h3> - <p class="meta">{{ page.date_formatted }}</p> - <p class="excerpt">{{ page.excerpt }}</p> - </div> - {% endif %} - {% endfor %} - </div> - - {% else %} <!-- Single page shows individual blog post --> - - <div class="post"> - {% if meta.title %}<h2>{{ meta.title }}</h2>{% endif %} - <p class="meta">{{ meta.date_formatted }}</p> - {{ content }} - </div> - - {% endif %}{% endraw %}- -
- Plugins can be created by creating a new PHP file and placing it in the "plugins" folder. Plugins can be placed
- in a sub folder if required. In your new plugin PHP file you need to create class with the same name as
- the file. So if you create a file called my_plugin.php
your class needs to be called My_Plugin
.
-
- Plugins can hook into Pico by adding functions with predefined names (hooks) to their class. For example you could
- add a custom template variable by adding a before_render
hook:
-
class My_Plugin { - - public function before_render(&$twig_vars, &$twig) - { - // Add a custom template variable - $twig_vars['my_custom_var'] = 'Hello World'; - } - - }- -
Below is a list of available hooks and their parameters:
-plugins_loaded()
config_loaded(&$settings)
request_url(&$url)
before_load_content(&$file)
after_load_content(&$file, &$content)
before_404_load_content(&$file)
after_404_load_content(&$file, &$content)
before_read_file_meta(&$headers)
file_meta(&$meta)
before_parse_content(&$content)
after_parse_content(&$content)
get_page_data(&$data, $page_meta)
get_pages(&$pages, &$current_page, &$prev_page, &$next_page)
before_twig_register()
before_render(&$twig_vars, &$twig, &$template)
after_render(&$output)
- Note that parameter variables are passed by reference - so that they can be modified. -
- -If you need to add custom meta variables you can do so using the before_read_file_meta()
hook. For example:
public function before_read_file_meta(&$headers)
- {
- $headers['layout'] = 'Layout';
- }
-
- Then in your content meta you would add the relevant meta value:
-/*
- Title: Example
- Description: This is a description
- Layout: 2col
- */
-
-
- You will then be able to access this value via the {% raw %}{{ meta.layout }}{% endraw %}
template variable.
- Help make Pico better by checking out the GitHub repository and submitting pull requests. If you find a bug - please report it on the issues page. -