Shortcodes are macros you place directly in the text of your content. Each macro is expanded and formatted through Drupal's theme layer when the content is displayed - similar in spirit to WordPress-style shortcodes, but reworked to fit Drupal's API conventions.

Shortcode is a small API module: a text format filter plus a plugin type for defining shortcode tags. Any module can supply new tags - including this one, via the bundled Basic Tags submodule below. Every tag is themeable, and tags can be nested inside each other (including inside another instance of the same tag) with no special recursion handling required.

As of 3.0.0, the module has been rewritten for Drupal 11.1+ and 12: object-oriented #[Hook] implementations, PHP-attribute-based plugin discovery (existing annotation-based plugins keep working), constructor-injected services, full type coverage, and automated unit + functional test coverage. If you maintain your own shortcode plugins, see UPGRADING.md in the module for the breaking changes in this release.

Macros come with this module

Shortcode basic tags module

  • [quote] Replace the given text formatted like as a quote.
  • [img] Show an image.
  • [highlight] Insert a span with highlight css class around the text.
  • [button] Insert a link formatted like as a button.
  • [dropcap] Replace the given text formatted like as a dropcap.
  • [item] Insert div or span around the text with some css classes.'
  • [clear] Insert a float-clearing div for a proper layout.
  • [link] Makes an aliased link to the given path.

Shortcode modules

Plans

* separate macros module from the API
* remove input filter dependency - push this functionality to a separate module
* tests
* D8 version - The planned release date of the beta version is 4. Jan 2016.

Docs, tutorials

* Nice tutorial by Ivan Zugec: How to Use WordPress Style Shortcodes in Drupal 7
* Boost your WYSIWYG with Shortcode module by salva.
* Shortcodes in Drupal? Yes you can! by Brianna Deleasa.

Sponsorship

...have a feature you'd like to sponsor? Or just want to sponsor this project? Get in touch!

Warning!

* Since 7.x-2.21 the Shortcode Video module moved to a separated project.
* Since 7.x-2.1 the Shortcode for wysiwyg module moved to a separated project.

Project information

Releases