Different templates in the same database according to category field

Different templates in the same database according to category field

by Gonzalo Gutierrez -
Number of replies: 2

First of all I know that I am asking for something that is surely not included in the database module.

I need to show different templates according to the category that was assigned to the entry.

For example, I have two categories:
-Books
-Infographs

When I filter by the category Infographics (performing a search) I would like to see a template with only the images.

While when filter by the Books category, I would like to display a template with publication details.

The goal is then to be able to display different templates according to the assigned category.

Is there any way of doing this?

Thanks


Average of ratings: -
In reply to Gonzalo Gutierrez

Re: Different templates in the same database according to category field

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Gonzalo,

You might be able to do this by using the method William Lu came up with for you in this forum https://moodle.org/mod/forum/discuss.php?d=334641, but with a slight modification. The modification is to have the database in your course with the filtered links for Books and Infographs listed right below the database and add the code to the template that I gave you for hiding empty rows.

You would need to set up your template so it has the fields for both categories, then use the same code I gave you for hiding empty table rows so that when viewing a book entry the empty infograph rows are hidden, and when viewing an infograph entry, the empty book rows are hidden.

There is another possibility, but I would need a preset of the database to test if it could be adapted to work.
Average of ratings: Useful (1)
In reply to AL Rachels

Re: Different templates in the same database according to category field

by Gonzalo Gutierrez -

Hi Al, thanks again for the interest and help.

I attached again the database preset, with the script you posted here: https://moodle.org/mod/forum/discuss.php?d=344634

If you want i could give you access to my development server in private message.


The idea is to have different look&feels when the entries are pdf and when they are images.  Somethink like the images attached, where i also identify with a red line which filter is active (is that possible?)


Very thankful!


Attachment Ambateca-Biblioteca.jpg
Attachment Ambateca-Infoteca.jpg