General developer forum

Adding a content filter

Picture of Justin Hunt
Re: Adding a content filter
Particularly helpful MoodlersPlugin developers

Generico is a general tool for implementing custom filters from css/js/html templates, without having to wrote a whole new plugin. So perhaps the solution in this case is a little roundabout but it might be ok. You would  want to tailor the following example to suit your use case. But if you look at the template it is quite straightforward.

Custom profile field: haircolor

Generico Template: haircolor

(Custom JS script field)

<span id="@@AUTOID@@" style="display: none">
if('@@color@@' == '@@USER:haircolor@@'){
document.getElementById('@@AUTOID@@').style='display: block';

Generico filter string (on a page, in an html block etc)

A message for red haired people:
 {GENERICO:type="haircolor",color="red"}You are special{GENERICO:type="haircolor_end"}

I have attached the haircolor template bundle if you want to try it out yourself.

Average of ratings: -