Giter Club home page Giter Club logo

craft-manytomany's Introduction

#Many to Many#

##Description## Many to Many is a CraftCMS plugin developed by Page 8. This plugin allows you to manage relationships in Craft from either of the entries that belong to the association. For example, if you have a recipe with many ingredients, and ingredients that belong to many recipes, you can manage the relationship from either the Recipe's entry or the Ingredient's entry.

##Installation##

  1. Download the plugin and make sure the parent folder is named manytomany
  2. Move the folder into your craft/plugins directory
  3. Install the plugin under Craft Admin › Settings › Plugins

##Usage##

  1. Create your initial relationship field using the Entries Field Type and attach it to your first section
  • This is done directly through Craft's native "Entries" field type
  • This example assumes this is done on the "Recipes" section creating a field called "Related Ingredients" that allows entries from the Ingredients section Recipes Screen
  1. Create another field that attaches the relationship using the Many to Many field type
  • This is done by creating a new field and selecting the Many to Many field type
  1. Customize your Settings
  • Linked Section will be the initial section that contains the relationship. (in our example Recipes)
  • Associated Field is the field on the other end of this relationship. (in our example Related Ingredients) Settings Screen
  1. Attach the newly created Many to Many field to your section Ingredients Screen

##Template Usage## Since this plugin relies on Craft's built in relationships, you can continue to use relationships just as you always have.

Recipes showing Related Ingredients

<h1>Related Ingredients</h1>
{% set relatedIngredients = craft.entries.section('ingredients').relatedTo(entry) %}
{% for ingredient in relatedIngredients %}
    {{ ingredient.title }}<br />
{% endfor %}

Ingredients showing Related Recipes

<h1>Related Recipes</h1>
{% set relatedRecipes = craft.entries.section('recipes').relatedTo(entry) %}
{% for recipe in relatedRecipes %}
    {{ recipe.title }}<br />
{% endfor %}

##To Do##

  1. Allow the field to work across all (or at least more) Element Types. Currently only supports Entries
  2. Allow custom ordering of the secondary relationship. Currently you can only order the primary relationship (by Craft's native ordering of the Entries field type)
  3. Fix a bug that doesn't allow it to work from the modal tab
  4. Other stuff I assume.

##Feedback?## Contact us on Twitter @Page8Online or visit us at page-8.com

##Version History##

  • 0.1.2 - Added translatable text
  • 0.1.1 - Optimized the cache control. Instead of clearing all Entry types from the cache, just clears records related to the changed element
  • 0.1.0 - Initial Release

###Notes###

  • Currently doesn't support locales
  • As always, use at your own risk

###License### This work is licenced under the MIT license.

craft-manytomany's People

Stargazers

Alex Carpenter avatar

Watchers

Tim Kelty avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.