Applying specific theme to specific page

Applying specific theme to specific page

by João Tentis -
Number of replies: 1
Hi all,

I want to change the theme on my 'report page' to classic, while the rest of moodle remains on my main theme, which is moove.

I've tried 2 different approaches:

1 - Changing the 'report' section inside $THEME->layouts from config.php inside the main theme folder, as shown below:

$THEME->layouts = [
'report' => [
'file' => 'report_theme.php',
'regions' => ['side-pre'],
'defaultregion' => 'side-pre',
],
];
Before I changed it, instead of 'report_theme.php', It was 'drawers.php'. The only thing I did was get the code from drawers.php from classic theme and paste it inside 'report_theme.php', which is a file I created inside 'moodle/theme/moove/layout' . It did nothing att all, it continued with the moove theme.

2 - I tried enabling the option to allow theme change from the url, while changing the url on 'moodle/reportbuilder/'.

First, It was:

admin_externalpage_setup('customreports', null, ['id' => $reportid], new moodle_url('/reportbuilder/edit.php'));
navigation_node::override_active_url(new moodle_url('/reportbuilder/index.php'));
Then I changed it to:

$theme_report='&theme=classic';
admin_externalpage_setup('customreports', null, ['id' => $reportid], new moodle_url('/reportbuilder/edit.php' . $theme_report));
navigation_node::override_active_url(new moodle_url('/reportbuilder/index.php' . $theme_report));
It did nothing to it aswell.

Any ideas on how I could do this? Sorry if the solutions I came with are stupid, I'm relatively new to this.
Average of ratings: -
In reply to João Tentis

Re: Applying specific theme to specific page

by João Tentis -
The solution in case anyone comes to the same problem:

$PAGE->force_theme('classic');
For it to work you have to make an exception inside 'force_theme' function to let it force theme change even when you have a theme selected, otherwise it won't work.
Average of ratings: Useful (1)