siezi / phile-tags
Tags for Phile CMS
1.0.0
2018-03-23 14:02 UTC
Requires
- phile-cms/phile: ^1.10 || dev-develop
- phile-cms/plugin-installer-plugin: ^1.0
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-11-29 05:26:51 UTC
README
Tag your pages. Show all pages with that tag.
A Phile plugin. Project home.
Installation
composer require siezi/phile-tags;
Activation
$config['plugins']['siezi\\phileTags'] = ['active' => true];
Usage
Add Tags to Pages
Add a new Tags
attribute to the page meta:
/*
Title: My First Blog Post
Tags: js, javascript, php
*/
The tags are available as meta.tags_array
in the template.
Shows Tags
To show tags for a page and link them to the tag-page:
{% if meta.tags_array is not empty %} {% for tag in meta.tags_array %} <a href="{{ base_url }}/tag/{{ tag }}"> #{{ tag }} </a> {% endfor %} {% endif %}
Create Tag Page Template
Create a new template "tag.html" in themes/<your_theme>/tag.html
. It is used to show all pages having a particular tag when calling the URL /tag/<tag-name>
.
<!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> {% endif %} {% endfor %} </body> </html>
Configuration
See the config.php
.