Your Moodle version

Filters: Generico

filter_generico
Maintained by Picture of Justin Hunt Justin Hunt
Generico is a simple filter for creating templates of code snippets and text that can be inserted into Moodle text areas.
646
258
20
Moodle 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9

Generico is a simple templating filter, that allows you to set up text and code snippet templates for use in Moodle text areas. It will allow 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 info box, tabset, accordian, lightbox, screenr 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. 



USAGE

You can define templates for use with the filter at:

Site Administration -> plugins -> filters -> Generico

A template consists of a "key", a "template," and some "defaults." 

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

{GENERICO:type=youtube,id=ABC12345678}


USER PROFILE VARIABLES

It is also possible now 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

If you are uploading Generico, first expand the zip file and upload the generico folder into:

[PATH TO MOODLE]/filters.

Then visit your Moodle server's notifications page.

Site Administration -> Notifications

Moodle will guide you through the installation. On the final page of the installation you will be able to register templates. You can choose to skip that and do it later from the Generico settings page if you wish.


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

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



Screenshots

Screenshot #0
Screenshot #1

Contributors

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

Comments RSS

Show comments
  • Picture of Vernon Spain
    Fri, Jul 31, 2015, 9:19 AM
    Awesome plugin... Saves so much time
  • Picture of Jeff White
    Thu, Sep 17, 2015, 2:33 AM
    awesome plugin! I have found so many uses for this plugin but feel free to call me an idiot for asking this. Is it possible for this plugin to query tables within moodle? Like tell it to show list the teachers of a course, show teachers picture in their profile, etc?
  • Picture of Justin Hunt
    Thu, Sep 17, 2015, 10:17 AM
    No it is not possible. It does not offer anyway to add custom data sources like that. As a template author your are basically limited to what you can do with html/JS and CSS. Maybe one day ..
  • Picture of dan k
    Tue, Nov 17, 2015, 11:24 AM
    can i increase the number of templates from 20 to 60?
  • Picture of Justin Hunt
    Tue, Nov 17, 2015, 11:58 AM
    Not from the user interface(yet). But it is possible by editing the code a little.
  • Picture of dan k
    Tue, Nov 17, 2015, 12:26 PM
    Thanks but that reply didn't really help hehehe... ;)

    is it by changing the following line:

    define('FILTER_GENERICO_TEMPLATE_COUNT', 20);

    on the lib.php?

    I've done that and it does give me more templates, but when i use any templates above 20 after setting it all up, the {generico code returns blank.

    am i missing something?
    can you help me?

    cheers,
    dan
  • Picture of Justin Hunt
    Tue, Nov 17, 2015, 12:38 PM
    that is basically what I meant. For the sake of easily implementing it in the future I put that constant in place. But I have not tested it how that would work. It might be necessary to bump the plugin version number, and go through the upgrade. I don't really like advising people to do something like that without even being sure it will work myself though. I will try later today and see
  • Picture of dan k
    Tue, Nov 17, 2015, 12:46 PM
    Thanks i really appreciate any help, as i've ran out of templates and i really need a few more to keep going with my moodle install, so if you can update me with your findings later on i'll really appreciate, as i don't really have time to wait for a new update of the plugin.

    cheers,
    dan
  • Picture of Justin Hunt
    Tue, Nov 17, 2015, 4:49 PM
    I figured I might as well just go through and implement this. So I did that. Both the Generico filter and the Atto Generico plugins have been updated on github. I won't put them on Moodle.org till I am pretty sure they work ok. But they work ok. In the Generico common filter settings there is now a setting for the number of templates, the default is 20. If you up that, you will need to click on the site admin -> notifications link for the new template settings to be picked up. ( i was surprised that worked). Please try it out and report back.

    Generico Filter Github: https://github.com/justinhunt/moodle-filter_generico
    Atto Github : https://github.com/justinhunt/moodle-atto_generico
  • Picture of Justin Hunt
    Tue, Nov 17, 2015, 4:49 PM
    I figured I might as well just go through and implement this. So I did that. Both the Generico filter and the Atto Generico plugins have been updated on github. I won't put them on Moodle.org till I am pretty sure they work ok. But they work ok. In the Generico common filter settings there is now a setting for the number of templates, the default is 20. If you up that, you will need to click on the site admin -> notifications link for the new template settings to be picked up. ( i was surprised that worked). Please try it out and report back.

    Generico Filter Github: https://github.com/justinhunt/moodle-filter_generico
    Atto Github : https://github.com/justinhunt/moodle-atto_generico
  • Picture of dan k
    Thu, Nov 19, 2015, 6:43 AM
    Awesome Justin! That works perfectly fine!!!! Thank you!!!!
  • Picture of Jarreau Mathys
    Thu, Dec 3, 2015, 8:19 PM
    Is there a way to pass a variable from an android system into moodle such as a device id? Or to look up something from outside of moodle? Thanks

  • Picture of Justin Hunt
    Thu, Dec 3, 2015, 9:38 PM
    That starts to stretch it a bit really. There are some preset variables that contain information passed in from PHP. If you were making a custom solution, you could just add to those by modifying filter.php (and friends). But if you wanted to do it via javascript, without modifying Generico, the information that you use in the template would need to be available from javascript. If it is, then you should be able to use it.
  • Picture of clement p
    Thu, Dec 17, 2015, 12:10 AM
    Hi,

    Thank you for your plugin. I use your plug-in to embed responsive video in my theme. Very usefull for me. Peoples can add video without use html code.
    I share my method, perhaps it can help someone.

    I use this setting with Generico Template template with this :

    1. The key that identifies template
    Youtube

    2. The body of template

    Bis : you can use Vimeo, it's works fine too.


    In my theme CSS, I add this :

    .videoWrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    padding-top: 0px;
    height: 0;
    }
    .videoWrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    }

    Best regards
  • Picture of clement p
    Thu, Dec 17, 2015, 12:11 AM
    Me again, point 2. The body of template is missing. Here it is :


    2. The body of template


    ++
1 2
Please login to post comments