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!
That’s awesome, I really find WordPress’ shortcodes to be its best feature. You should contribute it back to the main site… if I [have any useful comments | break it | am attacked by zombies from using your module] I will post another comment!
Thanks for this. Any chance you could post an example shortcode module to get us started? :-)
this looks very promising .
but not sure what to do next.
do you have a sample on your 4 and 5?
4.Add it to one of your setup’s filter bundle
5.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
sorry im a drupal newbie, so im kinda lost here
created a module
Call to undefined function add_shortcode
i edited the module weigths to 10 but still got the error
oh i cleared everything, enabled and disable my module and shortcode and i got this