Filters: FilterCodes

filter_filtercodes
Maintained by Picture of Michael Milette Michael Milette
The FilterCodes filter enables Moodle content creators to easily customize and personalize site and course content using plain text tags.
122 sites
154 downloads
13 fans

The FilterCodes plugin for Moodle enables you to insert plain text tags like {firstname} into your Moodle site or course content in order to to personalize the site to the individual students.

Examples uses for this plugin include:

  • Personalizing course content.
  • Display certain content depending on the user's role.
  • Conditionally display content depending on whether the user is enrolled in the current course.
  • Create links that normally require the users ID as part of the URL.
  • Insert default user information into Contact Form for Moodle forms.
Share with us how you use this plugin on your site.

The work for this project was sponsored by the kind folk at TNG Consulting Inc..

Once installed and enabled, the following plain-text tags (no HTML required) will become available to you anywhere that Moodle supports filtering:


Moodle metadata filters

  • {firstname} : Display the user's first name.
  • {surname} : Display the user's surname (family/last name).
  • {fullname} : Display the user's first name and surname.
  • {alternatename} : Display the user's alternate name. If blank, will display user's first name instead.
  • {city} : Display the user's city.
  • {country} : Display the user's country.
  • {email} : Display the user's email address.
  • {userid} : Display the user's ID.
  • {username} : Display the user's username.
  • {userpictureurl X} : Display the user's profile picture URL. X indicates the size and can be sm (small), md (medium) or lg (large). If the user does not have a profile picture or is logged out, the default faceless profile photo URL will be shown instead.
  • {userpictureimg X} : Generates an <img> html tag containing the user's profile picture. X indicates the size and can be sm (small), md (medium) or lg (large). If the user does not have profile picture or is logged out, the default faceless profile photo will be used instead.
  • {coursename} : Display the name of the current course or the site name if not in a course.
  • {mycourses} : Display an unordered list of links to all my enrolled courses.
  • {mycoursesmenu} : A second level list of courses with links for use in custom menus (filtering must be supported by the theme).
  • {categories} : Display an unordered list of links to all course categores.
  • {categoriesmenu} : A second level list of categories with links for use in custom menus (filtering must be supported by the theme).
  • {institution} : Display the name of the institution from the user's profile.
  • {department} : Display the name of the department from the user's profile.
  • {courseid} : Display a course's ID.
  • {wwwroot} : Display the root URL of the Moodle site.
  • {protocol} : http or https
  • {referrer} : Referring URL
  • {ipaddress} : User's IP Address.
  • {sesskey} : Moodle session key.
  • {recaptcha} : Display the ReCAPTCHA field - for use with Contact Form for Moodle. Note: Will be blank if user is logged-in using a non-guest account.
  • {readonly} : To be used within form input fields to make them read-only if the user is logged-in.

Conditionally display content filters

  • {ifenrolled}{/ifenrolled} : Will display the enclosed content only if the user is enrolled in the current course.
  • {ifnotenrolled}{/ifnotenrolled} : Will display the enclosed content only if the user is not enrolled in the current course.
  • {ifloggedin}{/ifloggedin} : Will display the enclosed content only if the user is logged in as non-guest.
  • {ifloggedout}{/ifloggedout} : Will display the enclosed content only if the user is logged out or is loggedin as guest.
  • {ifguest}{/ifguest} : Will display the enclosed content only if the user is logged-in as guest.
  • {ifstudent}{/ifstudent} : Will display the enclosed content only if the user is logged-in and enrolled in the course (no other roles).
  • {ifassistant}{/ifassistant} : Will display the enclosed content only if the user is logged-in as a non-editing teacher in the current course.
  • {ifminassistant}{/ifminassistant} : Will display the enclosed content only if the user is logged-in as a non-editing teacher or above in the current course.
  • {ifteacher}{/ifteacher} : Will display the enclosed content only if the user is logged-in as a teacher in the current course.
  • {ifminteacher}{/ifminteacher} : Will display the enclosed content only if the user is logged-in as a teacher or above in the current course.
  • {ifcreator}{/ifcreator} : Will display the enclosed content only if the user is logged-in as a course creator.
  • {ifmincreator}{/ifmincreator} : Will display the enclosed content only if the user is logged-in as a course creator or above.
  • {ifmanager}{/ifmanager} : Will display the enclosed content only if the user is logged-in as a manager.
  • {ifminmanager}{/ifminmanager} : Will display the enclosed content only if the user is logged-in as a manager or above.
  • {ifadmin}{/ifadmin} : Will display the enclosed content only if the user is logged-in as an administrator.

If the condition is not met in the particular context, the specified tag and it's content will be removed.

HTML and language tagging

  • {nbsp} : Is substituted for a non-breaking space when displayed.
  • {langx xx}{/langx} : Tag specific text in a particular language by wrapping the text in a plain text pair of {langx xx} {/langx} tags. This makes no visible changes to the content but wraps the content in an HTML <span lang="xx"></span> inline tag. As a result, screen readers will make use of this information to use a particular kind of pronunciation if the text is in a different language than the language of the rest of the page. This is required for compliance with W3C Web Content Accessibility Guidelines (WCAG 2.0)

For more information, see the documentation link.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

Picture of Michael Milette
Michael Milette (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Bert van der Hooft
    Fri, 6 Oct 2017, 3:16 PM
    Conflicts with plugin "Simple Certificate": they use {username} for printing first and last name on certificates. Using FilterCodes prints the username on the certificates. Raised a tracker at the Simple Certificate Plugin to change that. Meanwhile: be aware.
  • Picture of Bert van der Hooft
    Fri, 6 Oct 2017, 3:28 PM
    In order to avoid misunderstanding: FilterCodes is marvellous. Let's get it into quickmail and messaging too!
  • Picture of Michael Milette
    Wed, 18 Oct 2017, 6:39 AM
    Hi Bert, thanks! Glad you like it. It is unfortunate that there is a conflict with Simple Certificate, another great plugin I've used myself on several Moodle sites. Do take a look at the bug tracker where I have proposed a solution. As for getting it into Quickmail and messaging too, it's a Moodle filter. If the plugins make use of format_text() and format_string() functions, FilterCodes will work. It's up to the author of the plugins to apply the functions.
  • Picture of Michael Milette
    Wed, 18 Oct 2017, 6:41 AM
    Hi Blair, thanks for the suggestion. I have great news for you. The next release of FilterCodes will include a new tag called {alternatename}. And just for you, if it is empty, it will be substituted with the user's firstname. That way you don't need to deal with firstname or alternatename. It will just always work with {alternatename}. smile
  • Picture of Ralf Hilgenstock
    Mon, 13 Nov 2017, 4:46 PM
    Thanks great tool. Can you check the lang file. There are four empty strings.
  • Picture of Michael Milette
    Mon, 13 Nov 2017, 10:44 PM
    Hi Ralf,

    Thank you for bringing this up. Nice to know people check my work. These are actually empty/blank by design. Most people will not want to put anything in these fields.

    They are for special situations where a user is not logged into your website but you still want them to have a first, last name, username and email address. I can't think of a situation like that but they are available just in case. You'll find more information on this in the FAQ section of documentation. See:

    https://github.com/michael-milette/moodle-filter_filtercodes#when-a-user-is-logged-out-the-first-name-surname-full-name-email-address-and-username-are-empty-how-can-i-set-default-values-for-these-tags
  • Picture of Georg Wiesinger
    Wed, 15 Nov 2017, 3:33 PM
    Good morning,

    I noticed that the latest version 0.4.2 with the fixed https ReCPATCHA issue is only available via Github.

    Kind regards,
    George
  • Picture of Michael Milette
    Thu, 16 Nov 2017, 12:46 AM
    Oh darn! Sorry about that George. Looks like I uploaded the old version (with the new release notes) instead of the latest version. Thanks for letting me know. I've updated it on Moodle.org.
  • Picture of Blair F.
    Thu, 16 Nov 2017, 5:43 AM
    Hey, thanks, Michael! I just read your reply from October 17th!
  • Picture of Blair F.
    Thu, 16 Nov 2017, 6:03 AM
    I think this is one of the most awesome plugins! I hope you continue to support it forever!
  • Picture of genaguerry3320 genaguerry3320
    Thu, 16 Nov 2017, 8:58 PM
    Hi Bert, thanks! Glad you wish it. it's unfortunate that there's a conflict with easy Certificate, another nice plugin I've used myself on many Moodle sites. Do take a glance at the bug huntsman wherever I actually have planned an answer. As for obtaining it into Quickmail and electronic communication too, it is a Moodle filter. If the plugins build use of format_text() and format_string() functions, FilterCodes can work. It's up to the author of the plugins to use the functions.check itemguides.com
    You will get your answer.
  • Picture of Michael Milette
    Thu, 16 Nov 2017, 11:20 PM
    Why thank you Blair, that is so kind of you. I love working with Moodle and people like you and have every intention to continue the work I have started well into the future.
  • Picture of Kees Koopman
    Tue, 19 Dec 2017, 8:48 PM
    Hi,
    This is a great plug-in! Thanks!

    Is it possible to add a filtercode, such as: "IfMemberOfGroup xxx} and {/IfMemberOfGroup} (where XXX is the group-id)

    That would be very nice!

  • Picture of Michael Milette
    Wed, 20 Dec 2017, 4:41 AM
    Hi Kees,

    Great suggestion for a new tag! It should be possible. Just go to the Bug Issue Tracker at https://github.com/michael-milette/moodle-filter_filtercodes/issues and add your suggestion for the new tag. Use the subject line with "Feature request: {ifmemberofgroup}". I will also need you to include a detailed example of how you might want to use this feature.

    I can't make any promises but I will see if I can get it into the next release scheduled for May, around the same time as Moodle 3.5. If you need it sooner, you can submit a pull request. I am also available for hire.

    Thanks again for taking the time to write. I really appreciate it.

    Best regards,

    Michael
  • Picture of Kees Koopman
    Thu, 21 Dec 2017, 11:17 PM
    Hi Michael,

    Thanks for your quick response.
    I have made a feature request.

    In case you were going to program these weeks, it would be cool if this request can be granted smile.
    And otherwise I will wait until May 2018 smile.

    Thank you very much for this plug-in! This makes Moodle a whole lot more 'personal'.

    Sincerely,
    Kees Koopman.
1 2
Please login to post comments