PHPackages                             besteadfast/craft-preparse-field - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. besteadfast/craft-preparse-field

Abandoned → [jalendport/craft-preparse](/?search=jalendport%2Fcraft-preparse)Craft-plugin[Templating &amp; Views](/categories/templating)

besteadfast/craft-preparse-field
================================

A fieldtype that parses Twig when an element is saved and saves the result as plain text.

2.1.2(1y ago)10879.1k↓16.7%23[22 issues](https://github.com/jalendport/craft-preparse/issues)[2 PRs](https://github.com/jalendport/craft-preparse/pulls)MITPHPPHP ^8.0.2

Since Dec 2Pushed 1y ago8 watchersCompare

[ Source](https://github.com/jalendport/craft-preparse)[ Packagist](https://packagist.org/packages/besteadfast/craft-preparse-field)[ Fund](https://www.paypal.me/jalenconner)[ GitHub Sponsors](https://github.com/jalendport)[ RSS](/packages/besteadfast-craft-preparse-field/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (35)Used By (0)

Preparse Field for Craft
========================

[](#preparse-field-for-craft)

A fieldtype that parses Twig when an element is saved and saves the result as plain text.

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 5.0.0 or later and PHP 8.2.0 or later.

Installation
------------

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Then tell Composer to load the plugin:

    ```
     composer require jalendport/craft-preparse

    ```
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Preparse Field.

Usage
-----

[](#usage)

When creating a new Preparse field, you add the Twig that you want run to the field's settings. When an element with that Preparse field is saved, the code will be parsed and the resulting value saved as plain text.

It's worth noting that the Preparse field is only updated when the element the field is on is saved. If you grab data from a related element (like in the category title example below), and then update the related element, the preparsed value will not automatically be updated.

In the Twig, the element that the Preparse field is added to is available as a variable named `element`. It's best to use this variable (as opposed to something like `entry` or `asset`) because it's possible you add the same Preparse field to multiple element types. This also means that when a Preparse field is added to a Matrix, SuperTable, or Neo block, that block will be what is available as `element`, so if you want to access the element that the Matrix/SuperTable/Neo field belongs to, you will want to use `element.owner`.

### Examples

[](#examples)

If you have a category field on your element named `relatedCategory`, you can save the category title to the Preparse field by adding the following Twig to the field settings:

```
{{ element.relatedCategory.one().title ?? '' }}

```

This is useful for saving preparsed values to a field for use with sorting, searching, or similar things.

You can also do more advanced stuff, for instance performance optimizing. Let's say you have three different asset fields that may or may not be populated. Having to check these in the template may require a bunch of queries since you can't check if a field has a relation in Craft without actually querying for it. You could do something like this to get the id of the asset to use:

```
{% if element.smallListImage | length %}
    {{ element.smallListImage.one().id }}
{% elseif element.largeListImage | length %}
    {{ element.largeListImage.one().id }}
{% elseif element.mainImage | length %}
    {{ element.mainImage.one().id }}
{% endif %}

```

*You'd probably want to wrap that in `{% apply spaceless %} ... {% endapply %}` to make it more useful...*

Or you could just use it to do some bulk work when saving, like pre-generating a bunch of image transforms with [Imager X](https://plugins.craftcms.com/imager-x?craft4):

```
{% if element.mainImage | length %}
    {% set transformedImages = craft.imager.transformImage(element.mainImage.one(), [
    { width: 1000 },
        { width: 900 },
        { width: 800 },
        { width: 700 },
        { width: 600 },
        { width: 500 },
        { width: 400 },
        { width: 300 },
        { width: 200 },
        { width: 100 }
    ]) %}
{% endif %}

```

Preparse also has access to your site's template root, so you can even include local templates if you want to do more advanced stuff and/or want to keep your field's Twig in version control:

```
{% include '_partials/customPreparseFieldStuff' %}

```

Make sure that you always write solid Twig, taking into account that fields may not be populated yet. If an error occurs in your Twig, the element will not be saved. [Code defensively!](https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms#defensive-coding-in-twig)

Price, License, and Support
---------------------------

[](#price-license-and-support)

The plugin is released under the MIT license, meaning you can do whatever you want with it as long as you don't blame us. **It's free**, which means there is absolutely no support included, but you might get it anyway. Just post an issue here on GitHub if you have one, and we'll see what we can do. :)

Changelog
---------

[](#changelog)

See the [changelog file](https://github.com/jalendport/craft-preparse/blob/master/CHANGELOG.md).

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~86 days

Recently: every ~1 days

Total

29

Last Release

672d ago

Major Versions

1.4.0 → 2.0.02022-08-08

1.4.1 → 2.0.12022-12-02

1.5.0 → 2.1.12024-07-12

1.5.1 → 3.0.0-alpha.12024-07-12

PHP version history (2 changes)2.0.0PHP ^8.0.2

3.0.0-alpha.1PHP ^8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/953eb9987f37e578ae7ad0ee827a4c906da8b9e495055890b7790073d4db39a1?d=identicon)[besteadfast](/maintainers/besteadfast)

---

Top Contributors

[![aelvan](https://avatars.githubusercontent.com/u/2675644?v=4)](https://github.com/aelvan "aelvan (59 commits)")[![jalendport](https://avatars.githubusercontent.com/u/6537823?v=4)](https://github.com/jalendport "jalendport (52 commits)")[![carlcs](https://avatars.githubusercontent.com/u/7516543?v=4)](https://github.com/carlcs "carlcs (19 commits)")[![mmikkel](https://avatars.githubusercontent.com/u/298510?v=4)](https://github.com/mmikkel "mmikkel (5 commits)")[![khalwat](https://avatars.githubusercontent.com/u/7570798?v=4)](https://github.com/khalwat "khalwat (4 commits)")[![brandonkelly](https://avatars.githubusercontent.com/u/47792?v=4)](https://github.com/brandonkelly "brandonkelly (4 commits)")[![marionnewlevant](https://avatars.githubusercontent.com/u/695477?v=4)](https://github.com/marionnewlevant "marionnewlevant (3 commits)")[![bossanova808](https://avatars.githubusercontent.com/u/731309?v=4)](https://github.com/bossanova808 "bossanova808 (1 commits)")[![mildlygeeky](https://avatars.githubusercontent.com/u/273266?v=4)](https://github.com/mildlygeeky "mildlygeeky (1 commits)")[![benface](https://avatars.githubusercontent.com/u/1059139?v=4)](https://github.com/benface "benface (1 commits)")[![monachilada](https://avatars.githubusercontent.com/u/613183?v=4)](https://github.com/monachilada "monachilada (1 commits)")[![swixpop](https://avatars.githubusercontent.com/u/7113101?v=4)](https://github.com/swixpop "swixpop (1 commits)")

---

Tags

craftcraft-plugincraft3craftcmscraftcms-pluginfieldtypetwigcmsCraftcraftcmscraft-pluginfieldtypepreparse

### Embed Badge

![Health badge](/badges/besteadfast-craft-preparse-field/health.svg)

```
[![Health](https://phpackages.com/badges/besteadfast-craft-preparse-field/health.svg)](https://phpackages.com/packages/besteadfast-craft-preparse-field)
```

###  Alternatives

[jalendport/craft-preparse

A fieldtype that parses Twig when an element is saved and saves the result as plain text.

1086.4k](/packages/jalendport-craft-preparse)[wbrowar/guide

A CMS Guide for Craft CMS.

6154.5k1](/packages/wbrowar-guide)[nystudio107/craft-seomatic

SEOmatic facilitates modern SEO best practices &amp; implementation for Craft CMS 5. It is a turnkey SEO system that is comprehensive, powerful, and flexible.

1741.4M46](/packages/nystudio107-craft-seomatic)[nystudio107/craft-autocomplete

Provides Twig template IDE autocomplete of Craft CMS &amp; plugin variables

44204.4k13](/packages/nystudio107-craft-autocomplete)[viget/craft-classnames

Classnames plugin for Craft CMS

1115.5k1](/packages/viget-craft-classnames)[verbb/footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

213.3k](/packages/verbb-footnotes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
