Generico Filter - a template maker

Re: Generico Filter - a template maker

by Jason Lane -
Number of replies: 8

Justin, that did it! Your tweaking of the query made the object work properly - option (ii). 

I've since gone on to drastically edit the Javascript so more of the text is called from the db query - dynamic name, tags, description, and categorising the resource type based on 'Video', 'PDF' or 'Podcast' being one of the tags present.

Shared here if useful to others, heavily relies on bootstrap (tested with Boost Campus theme, but any Boost will do) but with some fumbling others can get it to work too.

Sample:


Average of ratings: Useful (2)
In reply to Jason Lane

Re: Generico Filter - a template maker

by Andreas Panagiotopoulos -

Hello! I am new to generico and I need your help.

Is there a filter that can print/show specific users with id as variable (or specific users' role) to a page?

Thank you!

Andreas

In reply to Andreas Panagiotopoulos

Re: Generico Filter - a template maker

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Andreas,

You can access the currently logged in use'sr info in the template with @@USER:[field]@@
e.g @@USER:username@@

If you need to use a specific user, eg "teachers favorite student this week" , you would pass in that user's id as a dataset variable and then set the SQL as something like
"SELECT * FROM mdl_user WHERE id=?"
You would use the data retrieved in the dataset to get the user information fields.

Read (a little) more about how to make those templates here (its for Poodll but its mostly the same for Generico):
https://support.poodll.com/en/support/solutions/articles/19000083258-how-do-widgets-work-for-developers-

See the section on viewcapability and hidecapability to see how to work with roles.

Look at the welcome user template to see how the user variable is used.
https://moodle.org/plugins/view.php?id=2101
In reply to Justin Hunt

Re: Generico Filter - a template maker

by Andreas Panagiotopoulos -

Thank you for the suggestions and the links.

I have done what you suggested - please see the image below.



The point how I will use the variables in the template.

Using '@@USER:firstname@@' and '@@USER:id@@', I get the firstname and the id of the logged in user and not these of user with id = 3.

Could you please tell me where I am wrong?

Thank you!

Andreas

In reply to Andreas Panagiotopoulos

Re: Generico Filter - a template maker

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
@@USER:[fieldname]@@ is the currently logged in user.
In the example above, it should be like this:

Then in your filter string you would do something like this:
{GENERICO:type=mycooltemplate,userid=3}

The retrieved data would then be available to use elsewhere in your template under: @@DATASET:[fieldname]@@

If there is more than one row retrieved (which will not be the case here), you will need to use javascript to deal with it. In that situation @@DATASET@@ would contain an array of records
In reply to Justin Hunt

Re: Generico Filter - a template maker

by Andreas Panagiotopoulos -

Thank you Justin for your support, really appreciated!

This is the solution, it works fine.

One more question please.. How I will retrieve user's profile picture? I can't find any reference.

@@DATASET:PIC@@ is not working. Do I have to change sql query and make a join with mdl_files in order to get user pic as a field in the query?

Thank you!

Andreas

In reply to Andreas Panagiotopoulos

Re: Generico Filter - a template maker

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Andreas, to retrieve the user's profile picture you access either of these two variables:
@@USER:pic@@ - this retrieves the html to display the picture on page
@@USER:picurl@@ - this retrieves the url of the picture.

Its hard to do from a user record obtained via a dataset though.
In reply to Justin Hunt

Re: Generico Filter - a template maker

by Andreas Panagiotopoulos -
Thank you Justin once more!

The problem is that with 'USER', you will manage to retrieve current logged in user details and not the specific user id..

Andreas
In reply to Andreas Panagiotopoulos

Re: Generico Filter - a template maker

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Andreas. Yes I understand. However I do not have a solution for that.
Possibly the userpic URL can be predicted or you can create some very clever SQL to pull it all out in one hit in the dataset. Or possibly you will need to relax that requirement.