2017 © Pedro Peláez
 

craft-plugin eagerbeaver

Allows you to eager load elements from auto-injected Entry elements on demand from your templates.

image

nystudio107/eagerbeaver

Allows you to eager load elements from auto-injected Entry elements on demand from your templates.

  • Saturday, September 30, 2017
  • by khalwat
  • Repository
  • 3 Watchers
  • 25 Stars
  • 394 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 89 % Grown

The README.md

No Maintenance Intended, (*1)

DEPRECATED

This Craft CMS 2.x plugin is no longer supported, but it is fully functional, and you may continue to use it as you see fit. The license also allows you to fork it and make changes as needed for legacy support reasons., (*2)

The Craft CMS 3.x version of this plugin can be found here: craft-eagerbeaver and can also be installed via the Craft Plugin Store in the Craft CP., (*3)

Eager Beaver plugin for Craft CMS

Allows you to eager load elements from auto-injected Entry elements on demand from your templates., (*4)

Screenshot, (*5)

Related: Eager Beaver for Craft 3.x, (*6)

Installation

To install Eager Beaver, follow these steps:, (*7)

  1. Download & unzip the file and place the eagerbeaver directory into your craft/plugins directory
  2. -OR- do a git clone https://github.com/nystudio107/eagerbeaver.git directly into your craft/plugins folder. You can then update it with git pull
  3. -OR- install with Composer via composer require nystudio107/eagerbeaver
  4. Install plugin in the Craft Control Panel under Settings > Plugins
  5. The plugin folder should be named eagerbeaver for Craft to see it. GitHub recently started appending -master (the branch name) to the name of the folder for zip file downloads.

Eager Beaver works on Craft 2.6.x., (*8)

Eager Beaver Overview

Craft's Eager-Loading Elements allows you to nicely optimize your templates by telling Craft to load everything you need in one big query., (*9)

The only rub is that you can't specify this eager loading behavior for entry, category, or product elements that are auto-injected into your template., (*10)

Eager Beaver is a small plugin that allows you to eager load sub-elements like Assets, Categories, Users, etc. to these auto-injected elements., (*11)

This is especially useful if you have pages that use Matrix block "content builders", and thus will typically result in loading a number of relations like Assets contained in Matrix blocks to render a page., (*12)

Configuring Eager Beaver

There's nothing to configure., (*13)

Using Eager Beaver

To use Eager Beaver, simply do something like:, (*14)

{% do eagerLoadElements(entry, [
    'author.userPicture',
    'blogCategory',
    'blogImage',
    'blogContent.image:image'
]) %}

Or you can use the more verbose syntax to do the same thing:, (*15)

{% do craft.eagerBeaver.eagerLoadElements(entry, [
    'author.userPicture',
    'blogCategory',
    'blogImage',
    'blogContent',
    'blogContent.image:image'
]) %}

The first parameter is the Element or array of Elements that you want to eager-load sub-elements into, such as an entry. If you pass in an array of Elements, they must all be the same type., (*16)

The second parameter is the same with: that you use for Eager-Loading Elements, and uses the exact same syntax., (*17)

In the above example: - author is a User that has an Assets field named userPicture added to it. - blogCategory is a Category field - blogImage is an Asset field - blogContent is a Matrix field that has an Assets field named image added to the block type image, (*18)

Eager Beaver Roadmap

Some things to do, and ideas for potential features:, (*19)

  • Release it

Brought to you by nystudio107, (*20)

The Versions

30/09 2017

dev-master

9999999-dev

Allows you to eager load elements from auto-injected Entry elements on demand from your templates.

  Sources   Download

The Requires

 

30/09 2017

dev-develop

dev-develop

Allows you to eager load elements from auto-injected Entry elements on demand from your templates.

  Sources   Download

The Requires

 

30/09 2017

1.0.1

1.0.1.0

Allows you to eager load elements from auto-injected Entry elements on demand from your templates.

  Sources   Download

The Requires

 

27/09 2017

1.0.0

1.0.0.0

Allows you to eager load elements from auto-injected Entry elements on demand from your templates.

  Sources   Download

The Requires