Generico Filter

Filters ::: filter_generico
Maintained by Justin Hunt
Generico is a simple filter for creating templates of code snippets and text that can be inserted into Moodle text areas.
Latest release:
2359 sites
529 downloads
91 fans
Current versions available: 4

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. 

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:type=wildthings,thing1=Sally}


Generico would replace the above filter string with:

"Inside this box are Sally and Silly"


The filter string must follow this format,

{GENERICO:type=templatekey,variable1=data1,variable2=data2}


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:type=youtube,id=ABC12345678}


USING PRESETS

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.


USING BUNDLES

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. 
https://moodle.org/mod/forum/discuss.php?d=324771


And there is a special category here on the Moodle plugins directory for sharing templates: 
https://moodle.org/plugins/browse.php?list=category&id=69



USER PROFILE VARIABLES

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.

e.g

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@@


INSTALLATION

Generico installs like any Moodle plugin. Please see here for more information on that process:
https://docs.moodle.org/en/Installing_plugins#Installing_directly_from_the_Moodle_plugins_directory

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

https://docs.moodle.org/31/en/filter_generico

https://poodll.freshdesk.com/solution/articles/19000083258-how-do-widgets-work-for-developers-


Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3

Contributors

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

Comments RSS

Comments

  • Mahesh Babu Telakula Sathyan
    Fri, 27 Jul 2018, 7:46 PM
    Hi,
    This is a fantasic plugin. It makes it easy to use templates and the changes get reflected in the content pages. I am try to add the "genrico"icon to the atto editor. The error that I get is The plugin 'generico' cannot be used; it does not appear to be installed. I am on Moodle 3.5 and Atto Text editor plugin is installed.
  • Justin Hunt
    Mon, 30 Jul 2018, 8:33 AM
    I think that you have not installed the Generico Atto icon plugin. It is separate to the filter. It is here: https://moodle.org/plugins/atto_generico
  • Yannick Vrolant
    Fri, 24 Aug 2018, 8:22 PM
    Hi,

    I have installed both the Generico Atto icon plugin and the filter (which I have activated) but the "G" button won't show in the Atto HTML editor : any idea of what might be missing to make it all work ? (am using Moodle 3.4 - Build: 20171113)

    Thanks for helping,
    Best,

    Yannick
  • Justin Hunt
    Fri, 24 Aug 2018, 8:31 PM
    Have you added the word "generico" in the Atto toolbar settings? You need to do that manually. Moodle doesn't do it for you. Thats the most likely issue. The other possible issue is that you are using TinyMCE without knowing it. There is no Generico icon for TinyMCE
  • Yannick Vrolant
    Fri, 24 Aug 2018, 8:35 PM
    Hi Justin,

    Thanks a million for a very quick and efficient answer as I had not added the "generico" word in the Atto toolbar settings !

    Best,

    Yannick
  • Yannick Vrolant
    Tue, 28 Aug 2018, 4:46 PM
    Hi,

    I'd like to make use of the Youtube Lightbox template in order to embed a video that is hosted on a Chinese platform (some Youtube equivalent). Here is the link to the original video : https://v.qq.com/x/page/s0629i76rm6.html

    And here is my own unsuccessful attempt at trying to modify the code for the template body, (am adding a few spaces in there for the code to be displayed as text in my comment) :
    < a href="#" data-featherlight="#@@AUTOID@@" >< div class="filter_generico_ytl" >< img src="https://puui.qpic.cn/vpic/0/@@videoid@@_160_90_3.jpg/0" width="@@width@@" height="@@height@@" / >< / div >< / a >< div style="display: none;" >< div id="@@AUTOID@@" >< iframe width="@@videowidth@@" height="@@videoheight@@" src="https://v.qq.com/iframe/player.html?vid=@@videoid@@&tiny=0&auto=0" allowfullscreen >< / iframe >< / div >
    Any idea on how to make this work ?
    Thanks a million for helping !

    Best,

    Yannick
  • Yannick Vrolant
    Tue, 28 Aug 2018, 4:48 PM
    (following my previous post) : if this may help, here are the embed code and iframe widget code available from the platform (am adding a few spaces for displaying the code as plain text) :

    HTML EMBED CODE =
    < embed src="https://imgcache.qq.com/tencentvideo_v1/playerv3/TPout.swf?max_age=86400&v=20161117&vid=s0629i76rm6&auto=0" allowFullScreen="true" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" >< / embed >
    IFRAME =
    < iframe frameborder="0" width="640" height="498" src="https://v.qq.com/iframe/player.html?vid=s0629i76rm6&tiny=0&auto=0" allowfullscreen >< / iframe >
  • Justin Hunt
    Thu, 30 Aug 2018, 8:20 AM
    Hi Yannick. Lets have this conversation in the Generico forum. I have posted a solution to using qq.com videos with Generico there. ..
    https://moodle.org/mod/forum/discuss.php?d=261896#p1512939
  • Marc Couture
    Thu, 11 Apr 2019, 1:53 AM
    Thank you for your Generico plugin. We use it at the Université de Sherbrooke and added the Lightbox 2 code to user available plugins. We noticed that the top right « close window » image background color is white (as a result, users doing a MouveOver don’t see the small « x » that lets them close the active window). Can you provide a the solution to this problem? Thank you.
  • Justin Hunt
    Thu, 11 Apr 2019, 8:40 AM
    Hi Marc. I will have a look. Thats just a 3rd party library wrapped up in a Generico template. Hopefully its a quickie. FYI You can use Lightbox2 template with your Poodll filter too.
  • Justin Hunt
    Thu, 11 Apr 2019, 9:12 AM
    @marc I sent an email. For anyone else, if you add this code to the Custom CSS area of that template, it will turn the background of the close link blue. tweak that to match what you want, or some variation of it to alter the close link foreground color.
    .fancybox-close-small, .fancybox-close-small svg {
    background: blue;
    }
  • Jeff M
    Mon, 5 Aug 2019, 1:38 PM
    Hello, I'm a private music teacher who is very excited about Moodle... BUT lost as to how to solve a problem. I need a simple way to show individual students information that is only for them. When each logs in, they see only what they need. Even though several students are enrolled in the same course ("Level 3" perhaps), I want each to log in and see the recording from their own lesson. Is this something I could use the Generico filter for? I read the documentation and I was still a little fuzzy on it. Thanks!
  • Daniel Neis Araujo
    Tue, 14 Apr 2020, 1:19 AM
    Hi,
    awesome plugin!
    Passing by to note that custom profile fields only works if their shortnames are in lower case. Didn't find it elsewhere, have to read the code, so noting here smile
  • Benjamin Schröder
    Fri, 14 Aug 2020, 6:28 PM
    Hi Justin, thank you very much for this amazing plugin. I would like to ask if you have any idea for this problem: When anybody uses the global search by Moodle they are going to see the plain text tags. Do I have to filter the filters out of the search? Any idea? Thank you very much!
  • Javier Tejera
    Tue, 13 Oct 2020, 8:11 PM
    Hi there,
    Is it possible to create a Line Chart with multiple lines? If so, how? I can't manage to do it :s i.e. to compare two different cities.
    Thanks!
Please login to post comments