Last week I wrote that we had a feature release planned for the holiday season. Some of you guessed it would be data forms support in the ListPages module. Looking at the top wishes it was quite a probable guess, and it was correct!
We have just deployed the improved version of ListPages with support for selecting pages by custom fields defined via data forms. We have chosen a simple syntax for querying but we are already thinking about extending it and adding more operators. The today's release should however provide you tools to play with and test our implementation.
Take a look at an example. Suppose we have a "band" category populated with entries for music bands defined by the data form:
label: Music type
label: Band website
label: My rating
1: I have seen worse
2: Better than Justin Bieber
3: Got used to it
6: Cannot live without it
Now, to select music bands that only play folk we can use:
[[module ListPages category="band" _type="2"]]
Note the underscore in front of the selection parameter — it denotes that the field is a custom one, defined by the data form.
You can mix several selection parameters, both custom fields and all previously supported ones. Criteria will be joined by the and operator, as previously.
Custom fields can be also used for sorting. To sort all bands by rating starting from the best to worst we can use:
[[module ListPages category="band" order="_rating desc"]]
That's it! We will update the documentation later on, but the above examples show it all.
Now here is a word of warning. Although this feature looks like a piece of cake, it was not that easy to implement. We hope it will work well for your sites (we have put it through thorough tests), but please treat it as a "beta" which can be changed or even pulled back if we discover serious issues.
Performance might not be super-stellar but is sufficient for sets up to thousands pages. We will work on improvements once we receive more feedback. Until then please use data form selectors on large categories carefully, especially when using multiple modules on a single page.
I hope you will like this new feature. What's more important, I believe it will enable you to build even greater sites and applications. Take care!