2017 © Pedro Peláez
 

craft-plugin craft-element-lists

Simple Element lists

image

flipboxfactory/craft-element-lists

Simple Element lists

  • Tuesday, May 1, 2018
  • by nateiler
  • Repository
  • 2 Watchers
  • 0 Stars
  • 519 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 1303 % Grown

The README.md

Element List Field Type for Craft CMS

Join the chat at https://gitter.im/flipboxfactory/craft-element-lists Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

Element List introduces a table-based element relational field type; perfect for large or growing element relations., (*2)

Screenshot, (*3)

New in Version 3

Element List field(s) now return a Relationship Interface (not the traditional Element Query Interface). As a result, if your app manipulates relationships in a custom manner (php/plugins/modules) some changes are required. Specifically, manipulating relations should use the add, remove, and save methods on the Relationship Interface (examples are below)., (*4)

Note: Accessing field data using the legacy Element Query Interface via TWIG is still supported; no code change are required., (*5)

Requirements

This plugin requires Craft CMS 3.2.x thru Craft 3.3.x., (*6)

Installation

Choose one of the following ways to add Element List to your project:, (*7)

  1. Composer:, (*8)

    Simply run the following command from your project root:, (*9)

    composer require flipboxfactory/craft-element-lists
    
  2. Craft CMS Plugin Store:, (*10)

    Within your Craft CMS project admin panel, navigate to the 'Plugin Store' and search for 'Element List'. Installation is a button click away., (*11)

Once the plugin is included in your project, navigate to the Control Panel, go to Settings → Plugins and click the “Install” button for Element List., (*12)

Additional information (including pricing) can be found in the Plugin Store., (*13)

Features

Element List brings the familiar element 'index' view to your fields. Built for large relation sets, Element List provides content publishers a filterable, table based view to related elements. Element List is as easy to configure as native relationships., (*14)

Here are some of the features at a glance: * Add/Remove relations in real time * Handles large relational sets (hundreds/thousands) * Sortable list view * Searchable list view * Developer friendly, (*15)

Templating (version 1 & 2)

Similar to native relational fields, an Element List field returns an Element Query Interface., (*16)

Loop through field relations:, (*17)

<ul>
    {% for relatedElement in element.fieldHandle.all() %}
        <li>{{ relatedElement.id }} - {{ relatedElement.someCustomField }}</li>
    {% endfor %}
</ul>

Templating (version 3)

An Element List field returns an Relationship Interface which is the primary interface for accessing and managing relationships., (*18)

Loop through field relations:, (*19)

<ul>
    {% for relatedElement in element.fieldHandle.collection.all() %}
        <li>{{ relatedElement.id }} - {{ relatedElement.someCustomField }}</li>
    {% endfor %}
</ul>

The legacy query operations from version 1 & 2 (above) are still accessible (but discouraged)., (*20)

Collections (new in Version 3)

In version 3 you'll begin to work with a Collection. These are super handy classes with various methods to interact with your data., (*21)

Eager Loading

Element Lists also supports eager-loading. Simply follow the native nested sets eager loading documentation., (*22)

Developers

Native relationship fields are not developer friendly; we aim to fix that in version 3 by introducing the concept of a Relationship Interface.
Here are a few examples:, (*23)

// Add two new users to the list
Entry::findOne(['id' => 1])
    ->userListField
    ->add([
        'nate@flipboxdigital.com',
        'damien@flipboxdigital.com'
    ])
    ->save();
// Remove one user and add another
Entry::findOne(['id' => 1])
    ->userListField
    ->remove('nate@flipboxdigital.com')
    ->add('damien@flipboxdigital.com')
    ->save();
// Remove all users
Entry::findOne(['id' => 1])
    ->userListField
    ->clear()
    ->save();

In the above examples, we're saving the relationships immediately; however if you make changes to your relationships and don't save, when the element is saved the relationship changes will also be saved., (*24)

Screenshots

Element Source Filter, (*25)

Inline Element Edit, (*26)

Select Modal, (*27)

Input Remove Action, (*28)

Field Settings, (*29)

Credits

The Versions