All Projects → sjelfull → craft3-collections

sjelfull / craft3-collections

Licence: MIT license
Clean up those complex templates with Laravel Collections

Programming Languages

PHP
23972 projects - #3 most used programming language
Twig
543 projects

Projects that are alternatives of or similar to craft3-collections

craft-entry-instructions
A simple fieldtype to add instructions.
Stars: ✭ 16 (-33.33%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
tablemaker
A user-definable table field type for Craft CMS
Stars: ✭ 39 (+62.5%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
visor
🕶 A simple admin overlay to get to the relevant areas of the Craft CMS control panel.
Stars: ✭ 25 (+4.17%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (-25%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
molecule
⚛️ Grab Twig components, CSS and JS files outside the primary template folder
Stars: ✭ 20 (-16.67%)
Mutual labels:  craft, craftcms, craftcms-plugin, craft3
Buttonbox
A collection of utility field types for Craft
Stars: ✭ 94 (+291.67%)
Mutual labels:  craft, craftcms, craft3
overflow.craft-plugin
A plain text Craft field type, with a soft or hard character limit.
Stars: ✭ 13 (-45.83%)
Mutual labels:  craft, craftcms, craftcms-plugin
craft-plugin-mix
Helper plugin for Laravel Mix in Craft CMS templates
Stars: ✭ 50 (+108.33%)
Mutual labels:  craft, craftcms, craft3
craft-json-snippets
Helps make CraftCMS models in .json
Stars: ✭ 17 (-29.17%)
Mutual labels:  craft, craftcms, craftcms-plugin
Craft Async Queue
Async Queue Handler for Craft 3
Stars: ✭ 80 (+233.33%)
Mutual labels:  craft, craftcms, craft3
craft-bulkedit
Bulk edit any set of elements
Stars: ✭ 22 (-8.33%)
Mutual labels:  craft, craftcms, craft3
craft-entriessubset
Craft field type plugin that extends the core Entries field type to give extra settings
Stars: ✭ 27 (+12.5%)
Mutual labels:  craft, craftcms, craftcms-plugin
Simplemap
A beautifully simple map field type for Craft CMS.
Stars: ✭ 136 (+466.67%)
Mutual labels:  craft, craftcms, craft3
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (+8.33%)
Mutual labels:  craft, craftcms, craftcms-plugin
padstone
Padstone is a Craft CMS starter kit with a curated configuration, Boilerplate templates, and handpicked plugins.
Stars: ✭ 18 (-25%)
Mutual labels:  craft, craftcms, craft3
Seo
SEO utilities including a unique field type, sitemap & redirect manager
Stars: ✭ 210 (+775%)
Mutual labels:  craft, craftcms, craft3
craft-commerce-widgets
Insightful widgets for Craft CMS Commerce stores
Stars: ✭ 33 (+37.5%)
Mutual labels:  craftcms, craftcms-plugin, craft3
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 (-41.67%)
Mutual labels:  craftcms, craftcms-plugin, craft3
Stamp-Craft
Plugin for adding timestamp to filenames.
Stars: ✭ 28 (+16.67%)
Mutual labels:  craftcms, craftcms-plugin, craft3
Craft Preparse Field
Field type that parses twig when an element is saved.
Stars: ✭ 103 (+329.17%)
Mutual labels:  craft, craftcms, craft3

Note: This plugin has been abandoned as Craft 4 includes Collections support.

Collections plugin for Craft CMS 3.x

Use Laravel Collections in Craft

Screenshot

Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

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

Collections Overview

Here is some good inspiration on what you can do with Collections:

Configuring Collections

Add your macros to the config file:

<?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:

<?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>

<div class="section hero is-primary">
    <div class="hero-body">
        <div class="container">
            <h1 class="title">Tags</h1>
            <p class="subtitle">
                Every tag on the site.
            </p>
        </div>
    </div>
</div>


<h2>Tag groups</h2>

<div class="section">
    <div class="container">
        <ul class="has-columns has-text-centered">
            {% set collection = craft.tags.group('media') | collect %}
            {% for letter, tags in collection.tagGroups() %}
                <div class="letter-group">
                    <h3 class="title is-1 letter">{{ letter }}</h3>

                    <ul>
                        {% for tag in tags %}
                            <li class="title is-5">
                                <a href="/tags/{{ tag.slug }}">{{ tag.title }}</a>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            {% endfor %}
        </ul>
    </div>
</div>

</body>
</html>

Brought to you by Superbig

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].