Filters: Generico Filter

Maintained by Picture of Justin HuntJustin Hunt
Generico is a simple filter for creating templates of code snippets and text that can be inserted into Moodle text areas.
1356 sites
51 fans
Current versions available: 2

Generico is a simple templating filter, that allows you to set up text and code snippet templates for use in Moodle text areas. It allows an unlimited number of templates to be registered. When Moodle encounters a Generico filter string it will use the data in the filter string to fill out the template, and insert it into the page. See it in action on the Generico course on the PoodLL demo site.

It is useful for ad-hoc template purposes where writing a new plugin would be overkill, or just for re-using common pieces of text. It can be used to centralise and manage the embedding of iframe content from video hosting services, and educational app providers.

In the latest version there are approx. 20 presets from which you can make templates. They include templates for an info box, tabset, accordian, lightbox and image gallery. And there is a companion Atto editor plugin for Generico. The combination of these two features make it possible to use Generico like the Wordpress shortcode plugins.

This 8 minute video walks through the basic Generico Filter and should give you a good idea of what it is, and how it works. 

How it works

Templates for use with the filter are available at:

Site Administration -> plugins -> filters -> Generico -> templates

A template primarily consists of a "key", a "template," and some "defaults." (It can also load CSS and Javascript. But for now lets keep things simple.)

The key is just a one word name, that tells Generico which template to use. 

The template is just passage of text that you want to use, and the parts of the template that you want to mark as variables you surround in @@ marks.

The defaults are a comma delimited list of variablename=value pairs. It is possible to specify multiple values for a single variable in the defaults. The Generico Atto editor plugin will display these values in a drop down list. eg size="100|120|140".  The first of the values will be the true "default."

Here is an example template.

templatekey: wildthings

template: Inside this box are @@thing1@@ and @@thing2@@

template defaults: thing2=Silly

A possible filter string for this "wildthings" template would look like this:


Generico would replace the above filter string with:

"Inside this box are Sally and Silly"

The filter string must follow this format,


The wildthings example above is trivial of course. Instead imagine using it to embed YouTube videos by registering the standard iframe code YouTube gives you, as a template. Then it would only be necessary to insert the id of the video in a generico filter string and the template would do the rest. e.g



Generico comes with about 20 template presets. By default they are not set up as templates yet. To create the actual template:

  1. Open an empty template settings page
  2. Select a preset from the dropdown list at the top of the page
    This will fill in the fields on the template settings page.
  3. Press the "Save Changes" button at the bottom of the page.


So that people can share the templates they have made, there is a system to share them called "bundles." On each template settings page there is a green bundle box.

If you click on the box, it will automatically download the "bundle" as a text file. If you then drag that bundle (or somebody else's bundle) onto the green bundle box of another template, it will fill the fields on that template settings page. Be sure to save the template after you have done that.

There are a number of bundles that people have shared over in the this forum thread.

And there is a special category here on the Moodle plugins directory for sharing templates:


It is also possible to add user profile variables to your templates. Just make the first part of the variable name USER: and the next part the name of the user profile field. It also works with custom profile fields. There are two "special" user profile fields, picurl and pic that respectively output the url of the user's profile pic, and their picture itself.


User's first name: @@USER:firstname@@

User's ice cream preference (custom profile field): @@USER:icecreampref@@
Users profile pic url: @@USER:picurl@@

User's profile pic:  @@USER:pic@@


Generico installs like any Moodle plugin. Please see here for more information on that process:

On the final page of the installation you will be able to register templates. its best to skip that step, and just press "save changes." Later you can do this from the Generico template settings pages.

After installing you will need to enable the Generico filter. You can enable the Generico filter at:

Site Administration -> plugins -> filters -> manage filters

More Documentation


Screenshot #0
Screenshot #1


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

Comments RSS


  • Picture of Данияр Нугуманов
    Thu, Dec 22, 2016, 5:01 PM
    Justin Hunt, hello, i have a question about DATASET templates
    Is it possible to improve sql query like this ?

    SELECT u.firstname, u.lastname,, c.fullname FROM mdl_user u, mdl_role_assignments r, mdl_context cx, mdl_course c WHERE ( = r.userid) AND (r.contextid = AND (cx.instanceid = @@COURSE:id@@) AND (r.roleid =3) AND (cx.contextlevel =50);

    i dont understand how it make
    help me plese
  • Picture of Justin Hunt
    Fri, Dec 23, 2016, 8:47 AM
    You should really post these questions on the forum. Because other people will notice and answer or get the benefit of the answer. And I can attach templates and resources to the post, which I can't do here.

    You can not put Generico variables in the Dataset field. The syntax is just the same as for the $DB get_records_sql function.

    You put any variables in the SQL as '?' marks, and any data or variables that should take their place in the Dataset vars field.
  • Picture of Данияр Нугуманов
    Tue, Jan 24, 2017, 12:59 PM
    Hello Justin, in forum you wroute that we should set Dataset Variables, but our moodle version is not compatible with fresh version where that field have
    Moodle version 2.7

    Can you ask me what version may help us?
    If there are not, can you update plugin for 2.7 moodle?
  • Picture of Justin Hunt
    Tue, Jan 24, 2017, 10:59 PM
    Oh, thats too bad! A lot has changed in Moodle 2.9. Because Moodle started to use AMD in Javascript. It would be possible to add the Dataset variables features to the old version of Generico. But I do not have time to make those changes. From Moodle 2.9 you can use the latest version of Generico. I hope that upgrading is an option for you.
  • Picture of Carlos Chiarella
    Fri, Feb 17, 2017, 1:50 AM
    We need some help here. We upgraded the version of the plugin from 1.3.0 to 1.3.8. The plugin is now stripping out the html tags when it renders the code.

    in html view:


    Vivaldi! Il prete rosso, or “the red priest” in Italian. This was
    Antonio Vivaldi’s nickname because of his red hair and because he had
    trained to become . . . a priest! At the age of 26, he was forced to
    abandon priestly duties because of ill health.

    Perhaps leaving the priesthood allowed him to focus all of his energy on
    music. He continued to expand his reputation as an accomplished violinist,
    conductor, and a highly prolific composer.

    So virtuosic was his violin playing that a German architect who heard him
    play in 1713 stated that “it is hardly possible that anyone has ever played
    or ever will play in such a fashion.”

    "} {GENERICO:type="narration_end"}

    When the page is in view mode, the

    tags are removed. We are using Moodle 3.0.7.
    It worked before when we were using Generico 1.3.0 and Moodle version 3.0.5. Any ideas of what might be happening?

  • Picture of Carlos Chiarella
    Fri, Feb 17, 2017, 1:52 AM
    The p tags are being removed.
  • Picture of Anderson Hsu
    Mon, May 1, 2017, 10:07 AM
    Dear all,
    How can we add database connection and sql by using Generico Filter plugin as shown as the link
    Thanks a lot.
  • Picture of Georg Wiesinger
    Wed, Jul 26, 2017, 6:31 AM
    Hi, congrats for this wonderful plugin! I tried to insert a lightbox (configured from your presets) on Moodle 3.3.1 but it didn't work, nothing happens, page only scrolls to top! Any idea what I'm might doing wrong?!

    Kind regards,
  • Picture of Hermann Keppler
    Thu, Aug 31, 2017, 8:05 AM
    Hi Justin! I'm trying to use Gernerico in Quickmail block. There is no "G" in the text editor and I have used the 'welcomesuser' template and modified it to 'dearusersfirstname'. My code snippit was placed in the body of the letter as '{GENERICO:type=dearusersfirstname},' (no quotes of course), and it didn't customize the output. should i have used HTML mode?? Hmm...
  • Picture of Justin Hunt
    Thu, Aug 31, 2017, 7:04 PM
    Hi Marvin, Is the Generico filter enabled at site admin -> plugins -> filters -> manage filters ? And have you installed the Generico plugin for the Atto editor and added "generico" in the Atto toolbar settings? You need to do both of these things.
  • Picture of Hermann Keppler
    Thu, Aug 31, 2017, 10:18 PM
    Thanks for the quick response, Justin! I have activated the Generico filter in the manage filters section before all this. I have just installed the Generico Atto editor icon and it now shows up in the Atto editor. Thank you! However, this Generico filter doesn't seem to work in Quickmail. It only displays: {GENERICO:type="dearusersfirstname"}. Should there be quotes in the Generico tag??
  • Picture of Justin Hunt
    Sat, Sep 2, 2017, 5:31 AM
    What happens if you put {GENERICO:type="dearusersfirstname"} into a forum post? My guess is that it will work, though Quickmail will not.
    Probably Quickmail doesn't pass the text through the filter system.

    Not sure if this is what you are trying to do, but trying to use Generico tags in email text really is problematic. If the text is filtered before it is sent. the user specific information won't be correct. Generico will use information of the logged in user. You might be able to get around that because Generico can perform custom database queries. But the next hurdle is to get Quickmail to send the post processed text. My guess is that you would need to customize Quickmail to pass the email text through the Moodle filter system, and then use that post processed text (not the original) when sending.
  • Picture of Hermann Keppler
    Sat, Sep 2, 2017, 7:18 AM
    Thanks again for the quick reply Justin. I was hoping for a "Well it worked for me" response. lol. I will think of another way. I will still have uses for Generico though. Thanks for the great plugin!
  • Picture of Alexander Lebeth
    Tue, Oct 10, 2017, 7:36 PM
    Hello, I would like to define a variable like variable=a|b|c but as a fourth option, it shgould be possible to enter manually a custom value. How is this possible? Or is there a workaround to achieve a similar functionality?
  • Picture of Justin Hunt
    Wed, Oct 11, 2017, 6:26 AM
    In the atto editor, you will just see a drop down list, and Generico provides no inbuilt way to present the 4th option as a text field. But in the actual filter string that is inserted on the page, of course its possible to just type in any value. You might say that in the instructions. Or if you wanted you could add the "other" field as a separate variable, and also have "other" as the 4th option. Then in the template you would check for the selection of the 4th option other, and if it was selected use the value of the other field. This is probably only going to be easy if you are using these variables in javascript. In plain html templates, it would be a bit of a head spin.
Please login to post comments