Retrieves a sorted array of similar content based on taxonomies that behave-like tags, see app/config/taxonomy.yml
.
Default usage:
{% set related = relatedcontentbytags(record) %}
Add options for more flexibility:
{% set related = relatedcontentbytags(record, { 'limit' : 5, 'pointsTag' : 5, 'pointsType': 100 }) %}
Default values are defined in config.yml
. Use these options to override these settings.
By default, this extensions searches through all available contenttypes. Use contenttypes
in options
to filter specific contenttypes:
{% set related = relatedcontentbytags(record, { 'contenttypes' : ['kitchensinks', 'snippets', '' ] }) %}
Non-existing contenttypes will be ignored.
The results from this extension are similar to how listings are handled in Bolt. Add the following in your template for a simple example.
{% for item in relatedcontentbytags(record) %}
<p><a href="{{ item.link }}">{{ item.title|e }}</a></p>
{% endfor %}
Similarity score is also accessible by {{ item.similarity }}
See config.yml
for more information. Options include:
limit
: the maximum number of results returnedpointsTag
: points per equal tagpointsType
: points if contenttypes are equalcontenttypes
: an array of contenttypes to search for.
Currently, this extension checks all tags-taxonomies and treats them as equal. A possible feature could be to add weight per contenttype and per taxonomy-type; or perhaps per tag (value). Or to ignore certain taxonomies. The desired behaviour would be dependant on the application, so no assumptions have been made (yet).