All Projects → aelvan → Similar-Craft

aelvan / Similar-Craft

Licence: MIT license
Find similar elements

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Similar-Craft

Inlin-Craft
Plugin for inlining files in templates.
Stars: ✭ 64 (+100%)
Mutual labels:  craftcms, craftcms-plugin, craft2
VarnishPurge-Craft
Craft plugin for purging Varnish when elements are saved.
Stars: ✭ 33 (+3.13%)
Mutual labels:  craftcms, craftcms-plugin, craft2
Stamp-Craft
Plugin for adding timestamp to filenames.
Stars: ✭ 28 (-12.5%)
Mutual labels:  craftcms, craftcms-plugin, craft2
Form-Builder
Craft CMS plugin that lets you create and manage forms for your front-end.
Stars: ✭ 16 (-50%)
Mutual labels:  craftcms, craftcms-plugin, craft2
craft-commerce-widgets
Insightful widgets for Craft CMS Commerce stores
Stars: ✭ 33 (+3.13%)
Mutual labels:  craftcms, craftcms-plugin, craft2
craft-router
A Craft CMS plugin for using URL segments as filtering criteria on an entry query.
Stars: ✭ 21 (-34.37%)
Mutual labels:  craftcms, craft2
events
Craft CMS Plugin for events management and ticketing.
Stars: ✭ 19 (-40.62%)
Mutual labels:  craftcms, craftcms-plugin
tags
A tag manager for Craft 3
Stars: ✭ 23 (-28.12%)
Mutual labels:  craftcms, craftcms-plugin
craft-select2
Filter / search a <select> using the popular Select2 fieldtype for Craft CMS
Stars: ✭ 18 (-43.75%)
Mutual labels:  craftcms, craftcms-plugin
digital-products
Sell digital products with Craft Commerce.
Stars: ✭ 14 (-56.25%)
Mutual labels:  craftcms, craftcms-plugin
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (-43.75%)
Mutual labels:  craftcms, craftcms-plugin
formie
The most user-friendly forms plugin for Craft CMS.
Stars: ✭ 73 (+128.13%)
Mutual labels:  craftcms, craftcms-plugin
craft-donkeytail
A Craft CMS fieldtype for content managing points on images.
Stars: ✭ 53 (+65.63%)
Mutual labels:  craftcms, craftcms-plugin
craft-plugin-doxter
Markdown Editor and Advanced Parser for Craft CMS
Stars: ✭ 23 (-28.12%)
Mutual labels:  craftcms, craftcms-plugin
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (-18.75%)
Mutual labels:  craftcms, craftcms-plugin
craft-assetusage
Craft plugin adds a column to see which assets are used or unused.
Stars: ✭ 28 (-12.5%)
Mutual labels:  craftcms, craftcms-plugin
Craft-User-Manual
📚 Help Section Plugin for Craft CMS.
Stars: ✭ 86 (+168.75%)
Mutual labels:  craftcms, craftcms-plugin
craft3-fallback-site
Failing requests in a multi-site install can fall back to other sites, to prevent 404 errors from missing or disabled entries.
Stars: ✭ 14 (-56.25%)
Mutual labels:  craftcms, craftcms-plugin
craft3-collections
Clean up those complex templates with Laravel Collections
Stars: ✭ 24 (-25%)
Mutual labels:  craftcms, craftcms-plugin
AssetSubfolderAccess
Limits user groups to only access certain asset subfolders
Stars: ✭ 18 (-43.75%)
Mutual labels:  craftcms, craft2

Similar plugin for Craft CMS

Similar for Craft lets you find elements, Entries, Categories, Commerce Products, etc, that are similar, based on... other related elements.

Installation

  1. Download the zip from this repository, unzip, and put the similar folder in your Craft plugin folder.
  2. Enable the plugin in Craft (Settings > Plugins)

The Similar plugin now available for use in your templates.

Usage

The plugin has one template method, find, which takes a parameters object with two required parameters, element and context. To find entries that are similar to entry, based on its tags in the Tagtag field entry.tags:

{% set similarEntriesByTags = craft.similar.find({ element: entry, context: entry.tags }) %}
<ul>
{% for similarEntry in similarEntriesByTags %}
    <li>{{ similarEntry.title }} ({{ similarEntry.count }} tags in common)</li>
{% endfor %}
</ul>

There is also a third, optional parameter that you probably would want to use most of the time, criteria. criteria lets you create the base ElementCriteriaModel that Similar will extend, giving you the ability to use all of Craft's usual goodies for your queries. If you'd want to limit the number of entries returned (good idea!), you could do it like this:

{% set limitCriteria = craft.entries.limit(4) %}
{% set similarEntriesByTags = craft.similar.find({ element: entry, context: entry.tags, criteria: limitCriteria }) %}

<ul>
{% for similarEntry in similarEntriesByTags %}
    <li>{{ similarEntry.title }} ({{ similarEntry.count }} tags in common)</li>
{% endfor %}
</ul>

The supported element types are Entry, Asset, Category, Tag, User and Commerce_Product. If you miss one, send me a feature request.

The context parameter takes either an ElementCriteriaModel, or a list of ids. If you want to find similar entries based on an entry's tags and categories, you could do:

{% set ids = entry.tags.ids() | merge(entry.categories.ids()) %}
{% set limitCriteria = craft.entries.limit(4) %}
{% set similarEntriesByTagsAndCategories = craft.similar.find({ element: entry, context: ids, criteria: limitCriteria }) %}

The returned model will be an extended version of the model of the element type you supplied. In the above examples where similar entries are returned, a Similar_SimilarEntryModel which extends EntryModel will be returned, giving you all the methods and properties of EntryModel in addition to count which indicates how many relations the entries had in common.

Matrix gotcha

Similar will not take relations inside Matrix blocks into account.

Price, license and support

The plugin is released under the MIT license, meaning you can do what ever you want with it as long as you don't blame me. It's free, which means there is absolutely no support included, but you might get it anyway. Just post an issue here on github if you have one, and I'll see what I can do. :)

Changelog

Version 1.0.0

  • Initial Public Release.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].