Search code examples
phpmoodle

Applying specific theme to specific page


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. Moodle version: 4.3.2


Solution

  • Try this to force a theme for a particular page

    $PAGE->force_theme('classic');