What is a shortcode?
A shortcode is essentially a snippet of text like [shortcode] that is a shortcut to a block of code written by an awesome developer.
Why are they useful?
Shortcodes are useful for giving non-technical users the ability to access technical functionality or just to simplify the process of adding sophisticated content.
I've heard of shortcodes in WordPress - are they the same thing?
From an end-user perspective; yeah, pretty much.
From a developer's perspective; there's a bit more work involved with integrating a shortcode in SilverStripe, but you also get a lot more power. We'll dive in to this a bit more in the followup.
How do I use shortcodes in SilverStripe?
SilverStripe has made the process of using shortcodes super simple. As long as your template has been developed correctly, there will be no need to touch any code. From the CMS, simply edit a page and insert the desired code in to the content region. If that doesn't work, ask your developer to integrate formatted code in to your template.
What shortcodes are built in to SilverStripe?
Shortcode text: [sitetree_link,id=33]
Description: Pulls in the url of a chosen page in your SiteTree. This is better than manually entering a URL, as your SiteTree structure may change, breaking any hard-coded URLs. This can also be added in the WYSIWYG by selecting text and clicking the Insert Link icon.
Shortcode text: [file_link,id=177]
Description: Same as above, but with files.
Shortcode text: [embed width=40 height=40]https://www.youtube.com/watch?v=YrblkMd-KMs[/embed]
Description: Use the OEmbed functionality to embed some external content. See below for more info.
Side note: while the official documentation states you should use a comma to separate values in a shortcode, spaces work as well - and using comma's in the [ embed] tag actually lead to an error in the SilverStripe CMS.
I'm sure there are other shortcode that are usable in SilverStripe, but from what I can see, the official documentation at the moment is a little bit lacking.
SilverStripe is awesome enough to have built-in embedding functionality for the following sources:
I'll add a short tutorial on how we can add support for other providers in the future.
How do I add more shortcodes to SilverStripe?
There are a bunch of ready-made SilverStripe modules that provide extra functionality available at the SilverStripe add-on directory
Alternatively, if you'd like to build your own Shortcode you can take a look at the follow-up technical article on "Creating Shortcodes" that will be live in the next couple of weeks.