wjzijderveld/sculpin-related-content-bundle

Sculpin Bundle 生成相关内容数据

1.0.1 2014-07-31 20:22 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:12:08 UTC


README

此Bundle是为与Sculpin一起使用而编写的。

安装

Composer

$ composer require wjzijderveld/sculpin-related-content-bundle ~1.0

使用方法

目前,使用方法非常简单,但以后可以进行扩展。它与Sculpin Taxonomy一起工作。

首先,您需要在内容上设置一些标签

---
title: Foo document
tags: [foo, bar]
---

在您想要显示相关内容的每个文档上,您定义将此内容与哪些标签关联

---
title: Foobar Document
tags: [foo, bar, foobar]
related_content:
    post_tags: [foo]
---

完成此操作后,您现在可以在模板中使用related_content变量(在这个例子中是Twig)

{% if related_content|length %}
    <div class="related">
        {% for item in related_content %}
            <a href="{{ item.url }}">{{ item.title }}</a>
        {% endfor %}
    </div>
{% endif %}