Skip to content

marionnewlevant/craft-mn_eager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MN Eager plugin for Craft CMS

access data that may or may not have been eager-loaded

This is the Craft 2 verion. The Craft 3 version is craft-agnostic_fetch

Installation

To install MN Eager, follow these steps:

  1. Download & unzip the file and place the mneager directory into your craft/plugins directory
  2. Install plugin in the Craft Control Panel under Settings > Plugins

MN Eager works on Craft 2.4.x, Craft 2.5.x., and Craft 2.6.x

MN Eager Overview

The code to fetch the elements from a Craft ElementCriteriaModel is different when the elements have been eager-loaded.

This plugin provides a uniform syntax for fetching elements whether or not they have been eager loaded.

Using MN Eager

The MN Eager functions are available as craft variables and as twig extensions.

Use any of:

  • craft.mneager.find(someField)
  • mnFind(someField)
  • someField | mnFind

Use any of:

  • craft.mneager.first(someField)
  • mnFirst(someField)
  • someField | mnFirst

Use any of:

  • craft.mneager.last(someField)
  • mnLast(someField)
  • someField | mnLast

Use any of:

  • craft.mneager.nth(someField, index)
  • mnNth(someField, index)
  • someField | mnNth(index)

Use any of:

  • craft.mneager.ids(someField)
  • mnIds(someField)
  • someField | mnIds

Use any of:

  • craft.mneager.total(someField)
  • mnTotal(someField)
  • someField | mnTotal

isEager

In addition to the fetching function, isEager will tell you whether an ElementCriteriaModel has been eager loaded:

  • craft.mneager.isEager(someField)
  • isEager(someField)
  • someField | isEager

MN Eager Changelog

1.0.0 -- 2016.03.16

  • Initial release

1.0.1 -- 2016.03.19

  • added last, nth, ids, total to round out the fetching functions.
  • added isEager
  • added twig filters and functions

Brought to you by Marion Newlevant

About

simplified fetching of possibly eager-loaded fields

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages