PHPackages                             restruct/silverstripe-shortcodable - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. restruct/silverstripe-shortcodable

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

restruct/silverstripe-shortcodable
==================================

Provides a simple button to insert Shortcodes into the HTMLEditorField + an API for developers to define shortcodes

5.0.5(3mo ago)21.0k↓33.3%4BSD-3-ClauseJavaScript

Since Jun 16Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/restruct/silverstripe-shortcodable)[ Packagist](https://packagist.org/packages/restruct/silverstripe-shortcodable)[ RSS](/packages/restruct-silverstripe-shortcodable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (21)Used By (0)

Silverstripe shortcode module
=============================

[](#silverstripe-shortcode-module)

Adds a [![](docs/screens/button.png)](docs/screens/button.png) button to HTMLEditorField for CMS users to insert Shortcodes in page content.
Shortcodes can optionally be represented in TinyMCE with a placeholder image.

[![](docs/screens/dialog.png)](docs/screens/dialog.png)This module is a partial-to-largely rewrite of sheadawson/silverstripe-shortcodable.
It depends on [Silverstripe Simpler](https://github.com/restruct/silverstripe-simpler) for some non-react UI functionalities (mainly the modal dialog).

Version Compatibility
---------------------

[](#version-compatibility)

BranchModule VersionSilverstripePHP`main``5.x`^6.0^8.2`ss4-5``4.x`^4.0 || ^5.0^7.4 || ^8.0**Note:** `composer.json` is the source of truth for exact version constraints.

Configuration
-------------

[](#configuration)

Register DataObjects or classes as shortcodable via Yaml config:

```
---
name: my_shortcodables
Only:
    classexists: Shortcodable\Shortcodable
---
Shortcodable\Shortcodable:
    shortcodable_classes:
        - My\Namespaced\Shortcodes\CurrentYearShortcode
        - My\Namespaced\Shortcodes\SomeOtherShortcode
        - ...
---
```

Required methods on shortcodable objects/classes
------------------------------------------------

[](#required-methods-on-shortcodable-objectsclasses)

Implement these methods on your shortcodable classes (may also be added via an Extension):

**(Required) shortcode parser callback:**
`public static function parse_shortcode(...)`
**OR:**
`public function MyCustomParser(...)` combined with:
`private static $shortcode_callback = 'MyCustomParser'`

**Parser method arguments:** (see [shortcode documentation](https://docs.silverstripe.org/en/4/developer_guides/extending/shortcodes/#parameter-values))
`($attrs, $content=null, $parser=null, $shortcode, $info)`

**NOTE: the parser method gets called on a singleton object instance.**
(So there's no `$this->ID` or `$this->owner->ID` etc.)

**Optional:**

- `private static $shortcode` (optional, else short ClassName will be used as \[ClassName\])
- `getShortcodeLabel()` (optional nice description for in dropdown, `singular_name()` or else `ClassName.Shortname` will be used as fallback)
- `getShortcodeFields()` (optional, attribute-formfields for popup)
- `getShortcodableRecords()` (optional, if applied to DataObject)
- `getShortcodePlaceholder($attributes)` (optional)

**Wrapping (optional):**In this module, `$shortcodable_is_block` and `$disable_wrapper` have been replaced with `$shortcode_close_parent`:

- `private static $shortcode_is_block` (optional, set to true if your shortcode output is a block-type html element)

If you set `$shortcode_close_parent` to true, the parent node will be closed before your shortcode output and reopened after.
Eg `Some [shortcode] content` would become `Some [shortcode] content`;

Shortcode placeholder images
----------------------------

[](#shortcode-placeholder-images)

To display a nice image instead of the raw shortcode in the CMS editor, implement a getShortcodePlaceHolder method on your shortcodable object:

```
/**
* Redirect to an image OR return image data directly to be displayed as shortcode placeholder in the editor
* (getShortcodePlaceHolder gets loaded as/from the 'src' attribute of an  tag)
*
* @param array $attributes attribute key-value pairs of the shortcode
* @return \SilverStripe\Control\HTTPResponse
**/
public function getShortcodePlaceHolder($attributes)
{
    // Flavour one: redirect to image URL (for this example we're also including the attributes array in the URL)
    Controller::curr()->redirect('https://www.silverstripe.org/apple-touch-icon-76x76.png?attrs='.json_encode($attributes));

    // Flavour two: output image/svg data directly (any bitmap but may also be SVG)
    // Hint: process attributes eg to show a set of image thumbnails wrapped in an SVG as gallery-placeholder
    $response = Controller::curr()->getResponse();
    $response->addHeader('Content-Type','image/svg+xml');
    $response->addHeader('Vary','Accept-Encoding');
    $response->setBody('

    ');
    $response->output();
}
```

Status
------

[](#status)

- TinyMCE button/plugin
- Shortcode form in popup dialog
- Custom/configurable shortcode independent of class name
- Custom/configurable shortcode parser callback methods
- Inserting new &amp; editing existing shortcode (+undo)
- Re-implement DataObjects as shortcodable (incl. getShortcodableRecords etc)
- Re-implement placeholders
- Check/re-implement(?) [BOM fix](https://github.com/sheadawson/silverstripe-shortcodable/pull/5) and in [ShortcodeController](https://github.com/sheadawson/silverstripe-shortcodable/blob/master/src/Controller/ShortcodableController.php#L240)
- Check/re-implement(?) [P/DIV wrapper fix](https://github.com/sheadawson/silverstripe-shortcodable/pull/51/files)
- Check/restore functionality for Uploadfields to load existing value
- Check/implement(?) [wrapping shortcodes](https://github.com/sheadawson/silverstripe-shortcodable/pull/73)

Refs:
-----

[](#refs)

- [General shortcode documentation](https://docs.silverstripe.org/en/4/developer_guides/extending/shortcodes/)
- [Shortcodable V2 documentation](https://github.com/sheadawson/silverstripe-shortcodable/blob/e2e2f1a2fa981d56e3c8ba63808fbe05da3d20f0/README.md)

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance79

Regular maintenance activity

Popularity23

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

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 ~93 days

Recently: every ~1 days

Total

19

Last Release

112d ago

Major Versions

4.0.14 → 5.0.02025-10-01

4.0.15 → 5.0.12026-01-19

4.0.16 → 5.0.42026-01-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d3680d6353e5f171543435b89965ba2588186ad7ec0ec97cbf572704fec2a4f?d=identicon)[micschk](/maintainers/micschk)

---

Top Contributors

[![sheadawson](https://avatars.githubusercontent.com/u/1166136?v=4)](https://github.com/sheadawson "sheadawson (60 commits)")[![micschk](https://avatars.githubusercontent.com/u/1005986?v=4)](https://github.com/micschk "micschk (39 commits)")[![oilee80](https://avatars.githubusercontent.com/u/1453382?v=4)](https://github.com/oilee80 "oilee80 (5 commits)")[![jonom](https://avatars.githubusercontent.com/u/1079425?v=4)](https://github.com/jonom "jonom (4 commits)")[![satrun77](https://avatars.githubusercontent.com/u/166450?v=4)](https://github.com/satrun77 "satrun77 (2 commits)")[![spekulatius](https://avatars.githubusercontent.com/u/8433587?v=4)](https://github.com/spekulatius "spekulatius (2 commits)")[![patjnr](https://avatars.githubusercontent.com/u/435055?v=4)](https://github.com/patjnr "patjnr (1 commits)")[![adrexia](https://avatars.githubusercontent.com/u/984753?v=4)](https://github.com/adrexia "adrexia (1 commits)")[![wernerkrauss](https://avatars.githubusercontent.com/u/1043925?v=4)](https://github.com/wernerkrauss "wernerkrauss (1 commits)")[![djmattski](https://avatars.githubusercontent.com/u/3836638?v=4)](https://github.com/djmattski "djmattski (1 commits)")[![ec8or](https://avatars.githubusercontent.com/u/1678184?v=4)](https://github.com/ec8or "ec8or (1 commits)")[![hubertusanton](https://avatars.githubusercontent.com/u/582188?v=4)](https://github.com/hubertusanton "hubertusanton (1 commits)")[![lozcalver](https://avatars.githubusercontent.com/u/1655548?v=4)](https://github.com/lozcalver "lozcalver (1 commits)")[![Neumes](https://avatars.githubusercontent.com/u/8358226?v=4)](https://github.com/Neumes "Neumes (1 commits)")

---

Tags

silverstripeshortcode

### Embed Badge

![Health badge](/badges/restruct-silverstripe-shortcodable/health.svg)

```
[![Health](https://phpackages.com/badges/restruct-silverstripe-shortcodable/health.svg)](https://phpackages.com/packages/restruct-silverstripe-shortcodable)
```

###  Alternatives

[sheadawson/silverstripe-shortcodable

Provides a GUI for CMS users to insert Shortcodes into the HTMLEditorField + an API for developers to define Shortcodable DataObjects and Views

5018.1k5](/packages/sheadawson-silverstripe-shortcodable)[kinglozzer/multiselectfield

A sortable multiple select field for managing many-to-many relations

1341.2k2](/packages/kinglozzer-multiselectfield)[wedevelopnl/silverstripe-elemental-grid

Elemental grid module

1014.1k2](/packages/wedevelopnl-silverstripe-elemental-grid)

PHPackages © 2026

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