pschmitt / phile-tags
Phile CMS 标签
dev-master
2015-01-10 15:56 UTC
Requires
- phile-cms/phile: >=1.0
- phile-cms/plugin-installer-plugin: >=1.0
This package is not auto-updated.
Last update: 2024-09-24 09:06:10 UTC
README
插件为Phile添加页面标签功能。[Phile](http://philecms.github.io/Phile) 的插件,基于Szymon Kaliski的[Pico Tags](https://github.com/szymonkaliski/Phile-Tags-Plugin),但只使用提供的钩子,不改变Phile核心。
它为您提供以下功能
- 如果是在
/tag/
URL上,则可以访问current_tag
变量 - 对于每个页面,
page.meta.tags_array
—— 页面的标签数组
安装
- 将此存储库克隆到
plugins/pschmitt/tags
mkdir -p ~http/plugins/pschmitt git clone https://github.com/pschmitt/phileTags.git ~http/plugins/pschmitt/tags # You may consider using a submodule for this git submodule add http://github.com/pschmitt/phileTags.git /srv/http/plugins/pschmitt/tags
- 重要:创建一个名为
tag
的新模板(即phile/themes/<your_theme>/tag.html
),当请求tag/
URI时将使用此模板。
- 在
config.php
中激活它
$config['plugins'] = array( // [...] 'pschmitt\\tags' => array('active' => true), );
用法
将新的 Tags
属性添加到页面元数据
/*
Title: My First Blog Post
Description: It's a blog post about javascript and php
Author: Dan Reeves
Robots: index,follow
Date: 2014/04/04
Tags: js, javascript, php
*/
配置
在 config.php
中您可以自定义
-
$config['tag_template']
—— 在tag/
页面上应使用哪个模板。此设置的默认值为'tag'
。 -
$config['tag_separator']
—— 用于分隔标签元数据(允许正则表达式,如'\s*'
)。其默认值为','
。
模板
现在您可以访问当前页面 meta.tags_array
和 pages
数组中的每个 page.meta.tags_array
tag.html
模板可能看起来像
<!DOCTYPE html> <head> <title>{{ meta.title }}</title> </head> <body> <h2>Posts tagged #{{ current_tag }}:</h2> {% for page in pages %} {% if page.meta.tags_array and current_tag in page.meta.tags_array %} <div class="post"> <h2><a href="{{ base_url }}/{{ page.url }}">{{ page.meta.title }}</a></h2> <div class="excerpt">{{ page.content }}</div> <span class="meta-tags">Tags: {% for tag in page.meta.tags_array %} <a href="{{ base_url }}/tag/{{ tag }}">#{{ tag }}</a> {% endfor %} </span> </div> <!-- // post --> {% endif %} {% endfor %} </body> </html>
许可证
MIT