2017 © Pedro Peláez
 

craft-plugin craft3-collections

Use Laravel Collections in Craft

image

superbig/craft3-collections

Use Laravel Collections in Craft

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 177 % Grown

The README.md

Note: This plugin has been abandoned as Craft 4 includes Collections support., (*1)

Collections plugin for Craft CMS 3.x

Use Laravel Collections in Craft, (*2)

Screenshot, (*3)

Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later., (*4)

Installation

To install the plugin, follow these instructions., (*5)

  1. Open your terminal and go to your Craft project:, (*6)

    cd /path/to/project
  2. Then tell Composer to load the plugin:, (*7)

    composer require superbig/craft3-collections
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Collections., (*8)

Collections Overview

Here is some good inspiration on what you can do with Collections:, (*9)

Configuring Collections

Add your macros to the config file:, (*10)

<?php
return [

    /** Add your macros here
     * "macros" => [
     *     'toUpper' => function () {
     *         return $this->map(function ($value) {
     *             return strtoupper($value);
     *         });
     *     },
     * ],
     *
     */

    "macros" => [

    ],

];

Using Collections

Group tags by letter:

Add this macro to your config:, (*11)

<?php
return [
    'macros' => [
        'tagGroups' => function () {
            return $this->groupBy(function ($tag) {
                return substr($tag->title, 0, 1);
            });
        }
    ],
];
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.1.2/css/bulma.css">
</head>
<body>



Tags

Every tag on the site. , (*12)

Tag groups

    {% set collection = craft.tags.group('media') | collect %} {% for letter, tags in collection.tagGroups() %}

    {{ letter }}

    {% endfor %}
</body> </html>

Brought to you by Superbig, (*13)

The Versions

20/07 2018

dev-master

9999999-dev

Use Laravel Collections in Craft

  Sources   Download

MIT

The Requires

 

cms collections craftcms craft-plugin craft

20/07 2018

2.0.2

2.0.2.0

Use Laravel Collections in Craft

  Sources   Download

MIT

The Requires

 

cms collections craftcms craft-plugin craft

02/07 2018

2.0.1

2.0.1.0

Use Laravel Collections in Craft

  Sources   Download

MIT

The Requires

 

cms collections craftcms craft-plugin craft

18/11 2017

2.0.0

2.0.0.0

Use Laravel Collections in Craft

  Sources   Download

MIT

The Requires

 

cms collections craftcms craft-plugin craft