Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Talk:Creating a theme based on boost

From MoodleDocs
Revision as of 01:19, 24 January 2017 by Richard Jones (talk | contribs) (Created page with "'''Note on loading presets''' This section of code in settings.php (I've slightly modified it) does not seem to load preset files from a folder in the theme root called preset...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note on loading presets This section of code in settings.php (I've slightly modified it) does not seem to load preset files from a folder in the theme root called preset and insert them into the drop-down list.

$files = $fs->get_area_files($context->id, 'theme_boostbase', 'preset', false, 'itemid, filepath, filename', false);
    $choices = [];
    foreach ($files as $file) {
        $f = $file->get_filename();
        $choices[$f] = $f;
    }
    $choices['preset-morecandy.scss'] = 'preset-morecandy.scss';
    $choices['preset-morecandyiip.scss'] = 'preset-morecandyiip.scss';    

Note I've changed it slightly in an attempt to trace through what's happening. When explicitly inserted as above, they will appear in the drop-down. However, then there is a problem getting them to actually load in the lib function

function theme_boostbase_get_main_scss_content($theme)

Again I've altered the code a bit:

$context = context_system::instance();
    if ($filename == 'default.scss') {
        // We still load the default preset files directly from the boost theme. No sense in duplicating them.
        $scss .= file_get_contents($CFG->dirroot . '/theme/boost/scss/preset/default.scss');
    } else if ($filename == 'plain.scss') {
        // We still load the default preset files directly from the boost theme. No sense in duplicating them.
        $scss .= file_get_contents($CFG->dirroot . '/theme/boost/scss/preset/plain.scss');

    } else if ($filename) {
        // Check the preset file area for theme_boostbase.
        $presetfile=null;
        $presetfile = $fs->get_file($context->id, 'theme_boostbase', 'preset', 0, '/', $filename);
        if($presetfile) {
          $scss .= $presetfile->get_content();
        }
    } else {
        // Safety fallback - maybe new installs etc.
        $scss .= file_get_contents($CFG->dirroot . '/theme/boost/scss/preset/default.scss');
    }

In this case it doesn't load any content from the file (loses all theming) and doesn't fallback to safety either. Any ideas appreciated if someone has seen the same issue.

Also apologies if this is the wrong place to post this (as opposed to a theme forum or Damyon's github).

09:16, 24 January 2017 (AWST)