Change activities layout, similar to course cards

Change activities layout, similar to course cards

by Bruno Moreira -
Number of replies: 8

Hi,

I want the activities inside the courses, to be displayed in image cards, as the courses are. Example:

d

How can this be done?

Is something that can be done with the default moodle? Only with themes? Custom code?


Thanks for the help

Average of ratings: -
In reply to Bruno Moreira

Re: Change activities layout, similar to course cards

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Can be done but needs PHP and SCSS / CSS code. It's not trivial. But either a theme or a course format can override / use its own 'course renderer' to make it happen. To explain any further will take ages and a significant amount of detail!  Not sure about the image bit though, that is a tricky one.
In reply to Gareth J Barnard

Re: Change activities layout, similar to course cards

by Bruno Moreira -
Thanks for reply.
Do you know any theme that can do this?
About the CSS code, where should it be done? Inside moodle platform? Some file hosted in server? Also, if you know how it can be done, and provide some code to start with, would be great.
In reply to Bruno Moreira

Re: Change activities layout, similar to course cards

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
I don't know of any theme.
You need to write both PHP and CSS code. Needs to be in a custom theme or course format. To start look at what /course/renderer.php methods pertaining to course modules, then look at the developer docs (https://docs.moodle.org/dev/Main_Page) and learn about renderers and automatic class loading. You'll also need to have skills in OO PHP and CSS.
In reply to Gareth J Barnard

Re: Change activities layout, similar to course cards

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
@Bruno Is the idea of the picture to be an image per activity type (eg replacing the icons with an image) or that each activity may have its own picture so that 3 separate forums (for example) might have 3 different pictures?
If the former, probably achievable in the renderer when being overridden as Gareth has already mentioned. If the latter, then would also need some work to add an image field to every activity, unless you were happy to stipulate that the description field was used only as somewhere to put that image and then the tile displayed the description as the background...🤔
In reply to Richard Oelmann

Re: Change activities layout, similar to course cards

by Bruno Moreira -
Hi,
I believe is the first one. The idea is to have the layout always displayed like the course cards, until reach the actual activity, for example, you open a course, and you see more cards, like if they were sub-disciplines or categories, that could have more and more inside, until reach the actual activity. This is a modern layout i've seen in other moodle sites, and i don't know how they did it.