Adding a content filter

Re: Adding a content filter

by Justin Hunt -
Number of replies: 0
Picture of Particularly helpful Moodlers Picture of Plugin 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">
<script>
if('@@color@@' == '@@USER:haircolor@@'){
document.getElementById('@@AUTOID@@').style='display: block';
}
</script>


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.