WordPress’ Shortcode API is a really cool thing, and since I’m working on a Drupal site these days I’ve been looking for something similar. Unfortunately I couldn’t find anything… There are some implementations out there but the ones I found and tested always come pre-bundled with specific tags and don’t always provide an extensible and stable logic.
So I made mine!
Most of my work simply consisted in copying/pasting the code in WordPress’ shortcodes.php and binding it into a Drupal filter. Easy enough.
Now if you want to use it, you have to:
- Get the module
- Add it to your “modules” directory
- Enable it
- Add it to one of your setup’s filter bundle
- Write your own module where you’d implement one or more Shortcodes (via add_shortcode) and make sure you add “dependencies[] = shortcodes” in your .info file
You might experience a nasty “Call to undefined function add_shortcode“. If so, you have to change you module implementation’s weight, either directly in your database, or thanks to the cool Utility module. Set it to 10 and you’re set!