Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattstauffer/craftcms-prune
CraftCMS Prune Twig plugin
https://github.com/mattstauffer/craftcms-prune
Last synced: 15 days ago
JSON representation
CraftCMS Prune Twig plugin
- Host: GitHub
- URL: https://github.com/mattstauffer/craftcms-prune
- Owner: mattstauffer
- Created: 2014-06-12T13:13:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-27T00:41:34.000Z (about 9 years ago)
- Last Synced: 2023-03-12T11:17:17.051Z (over 1 year ago)
- Language: PHP
- Size: 214 KB
- Stars: 49
- Watchers: 4
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Twig Prune for [Craft CMS](http://buildwithcraft.com/)
Add a Twig filter for CraftCMS templates to "prune" out fields of entries.
## Installation
1. Move the `prune` directory into your `craft/plugins` directory.
2. Go to Settings > Plugins from your Craft control panel and enable the `prune` plugin## Usage
The primary reason for this is to control the fields being output to `json_encode`.```twig
{{ craft.entries.section('news').find() | prune(['title', 'body']) | json_encode() | raw }}
```The above template will get all entries from the "news" section, grab just the title and body fields from each, and then output it to JSON.