mattstauffer / craftcms-prune

CraftCMS Prune Twig plugin
49 stars 2 forks source link

Attempting to return sensible defaults for non-text fields. #4

Closed howardroark closed 8 years ago

howardroark commented 9 years ago
  1. In the event of an Asset type, return the url of the first asset in the array.
  2. In the event of a MatrixBlock type, assume a depth of one and return an array off all content objects which have been pre-filtered to remove defaults.

I also add the ability to choose a key which each entry object is mapped to. For example you may want to tie each object to id instead of returning an array of objects.

mattstauffer commented 8 years ago

@howardroark Apparently I haven't been getting notifications for PRs and Issues on my personal issues. Apologies!

I have't actually done much with non-text fields lately, so my brain isn't here too much--does this choose just the first for each instead of giving an array of results? I would presume we'd want an array in most contexts but maybe I'm missing the point/context?

howardroark commented 8 years ago

That does make more sense... Return an array of URLs vs just the first URL :) The goal is sort of to have a simplistic alternative to the Element API which is a lot more PlugNPlay.