You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-9Lines changed: 17 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -422,11 +422,17 @@ You can now use shortcodes in Twig templates and process them with the `|shortco
422
422
{{ twig_text|shortcodes }}
423
423
```
424
424
425
-
## Developing Shortcode Plugins
425
+
## Custom Shortcodes
426
426
427
-
The **Shortcode Core** plugin is developed on the back of the [Thunderer Advanced Shortcode Engine](https://github.com/thunderer/Shortcode) and as such loads the libraries and classes required to build third party shortcode plugins.
427
+
### Simple Way
428
+
429
+
First, configure a directory from which custom shortcodes are loaded. Edit `user/config/plugins/shortcode-core.yaml` like follows (create it if it does not exist):
430
+
431
+
```yaml
432
+
custom_shortcodes: '/user/custom/shortcodes'
433
+
```
428
434
429
-
The simplest way to add your own custom shortcodes, it to simply create a new shortcode in a directory (e.g. `user/custom/shortcodes`) such as this simple one to allow for strike-through text:
435
+
To add a custom shortcode, create a PHP file that defines a new shortcode class. For example, to create a shortcode for ~~strikethrough~~ text, save the following code as `user/custom/shortcodes/StrikeShortcode.php`:
430
436
431
437
```php
432
438
<?php
@@ -445,13 +451,15 @@ class StrikeShortcode extends Shortcode
445
451
}
446
452
```
447
453
448
-
Then simply set the plugin to look in this directory for custom shortcodes by editing the `user/config/plugins/shortcode-core.yaml` file (create it if missing):
454
+
Note that the class name (`StrikeShortcode`) must match the file name for the shortcode to work.
449
455
450
-
```yaml
451
-
custom_shortcodes: '/user/custom/shortcodes'
452
-
```
456
+
`[strike]text[/strike]` should now produce strikethrough text.
453
457
454
-
The more flexible approach is to create a custom plugin to do provide a tidy package for your shotdcodes.
458
+
### As a Custom Plugin
459
+
460
+
The more flexible approach is to create a custom plugin.
461
+
462
+
The **Shortcode Core** plugin is developed on the back of the [Thunderer Advanced Shortcode Engine](https://github.com/thunderer/Shortcode) and as such loads the libraries and classes required to build third party shortcode plugins.
455
463
456
464
We introduced a new event called `onShortcodeHandlers()` that allows a 3rd party plugin to create and add their own custom handlers. These are then all processed by the core plugin in one shot.
457
465
@@ -524,4 +532,4 @@ However, there are situations when you need to process the shortcode **before**
0 commit comments