Shortcodes

Filters ::: filter_shortcodes
Maintained by Frédéric Massart ⭐
Allows users to inject and modify content using shortcodes provided by other plugins.
Latest release:
1758 sites
928 downloads
49 fans
Current versions available: 1

This plugins allows users to use shortcodes in content throughout Moodle to inject or modify content with ease. The shortcodes are provided by other Moodle plugins.

Usage

A shortcode is constituted of a word between square brackets. There are two types of shortcodes: the ones that wrap content, and the ones that do not. Those that do wrap content MUST have a closing tag. Here is an example using [useremail] which prints the current user's email, and [toupper] which wraps content and makes it uppercase.

Your registered email address is: [useremail].

[toupper]This text will be uppercased[/toupper].

You can also nest the shortcodes, let's make the user's email address uppercase.

Your registered email address is: [toupper][useremail][/toupper].

Some shortcodes support arguments. Those are declared in the same manner as HTML attributes. Here is an example of a shortcode that would add a collapsible section with a height of 100, and which would be collapsed by default:

[section height="100" collapsed]

Attribute values do not require to be wrapped between double quotes, but it is recommended. When the attribute does not have a value, it is considered to be true. Single quotes cannot be used in lieu of double quotes.

List of shortcodes

Once the plugin is installed, the list of all available shortcodes and documentation on how to use them will be available at the URL: http://your-moodle-site/filter/shortcodes/index.php. By default this page is available to all logged in users, though this can be changed using the permission filter/shortcodes:viewlist.

Plugins supporting shortcodes

Your plugin supports shortcodes? Let us know!

For developers

Developers can easily add support shortcodes in their plugin. See the documentation for more information.



Provided by
Branch Up

Screenshots

Screenshot #0

Contributors

Frédéric Massart ⭐ (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Plugins bot
    Tue, 8 May 2018, 10:50 AM
    Approval issue created: CONTRIB-7292
  • Boris Malysh
    Sat, 18 Apr 2020, 1:05 PM
    Hello! And thanks for the plugin!
    But unfortunately the shortcodes list (http://your-moodle-site/filter/shortcodes/index.php) is only showing [firstname], [fullname] and [off] .
    The shortcodes I've seen in the description above ( [useremail], [toupper], [section height="100" collapsed]... they look very promising. But they're not there.
    How can I add them to the list and use?
    Are there any other shortcodes ready or use?
  • Frédéric Massart ⭐
    Mon, 20 Apr 2020, 12:57 PM
    Hi Boris,

    This plugin does not come with a list of shortcodes by default, except for the 3 that you found. We created this plugin to allow other developers to add shortcodes to their own plugins. Keeping the built-in shortcodes to a minimum was very important to keep the performance impact to its minimum unless new features are needed. There are tons of shortcodes we could be adding, if you are looking for a plugin that provides a similar functionality but comes with a lot of pre-defined shortcodes, please search for "filtercodes".
  • Joseph Liaw
    Thu, 16 Jul 2020, 8:55 AM
    Hi Frederic:
    Any plans on updating for 3.8 since 3.8 is Long Term Support? Thanks for sharing your great work with teachers around the world to help gamify their courses to make it more engaging and fun for students!
  • Frédéric Massart ⭐
    Thu, 16 Jul 2020, 12:06 PM
    Hi Joseph. Oh, we had forgotten to update the compatible versions! We just did. We've been using the plugin on more recent Moodle versions without any issues. Please make sure to let us know if you experience any issues.
  • Matt Musgrave
    Tue, 12 Jul 2022, 9:46 PM
    Hi Frederic,

    I can't find any documentation on how to use this plugin with your LevelUp+ plugin. I would like to know how to use the [xpdrop] feature, and how to change the amount of XP each drop gives. Could you point me to the documentation, or let me know how to do it in your reply. Much appreciated.
  • Frédéric Massart ⭐
    Wed, 13 Jul 2022, 11:37 AM
    Hi Matt, we responded to your other comment left on Level Up XP's page, but in a nutshell drops must be created via the Drops page in Level Up XP.
  • Lucie Grenouilleau
    Mon, 1 May 2023, 10:18 PM
    Hello!
    I use shortcodes in combination with Level Up XP+.
    Initially I thought the short code xppoints would show the current number of points for a user but it only shows a specific number of points.
    Is there anyway to have the current number of points showed? For example, "Hello [firstname], you currently have XXX points."
  • Frédéric Massart ⭐
    Wed, 3 May 2023, 2:17 PM
    Hi Lucie,

    Thank you for your feedback. Shortcodes are defined by their respective plugins, so it would be the responsibility of Level Up XP to declare a short code to display the points of a user.

    Having said that, you are correct. The xppoints shortcode is meant to be used to display a certain amount of points, for instance to advertise the points received for completing an activity. That shortcode cannot be used to display the user's point total.

    Such shortcode does not yet exist, but it is a good suggestion and we'll definitely consider adding it in our next release.

    Thank you!
    Fred
Please login to post comments