siezi/phile-tags

Tags for Phile CMS

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Type:phile-plugin

1.0.0 2018-03-23 14:02 UTC

This package is auto-updated.

Last update: 2024-03-29 03:26:07 UTC


README

Build Status

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.