Moodle - Creating Themes / Theme Simple Study

Moodle - Creating Themes / Theme Simple Study

by A SSSS -
Number of replies: 5

Hi, I'm creating a theme for Moodle and I can not install it or take tests, the issue has only 3 files and .css is blank, only for testing ...


arquive config.php (Is the theme of the root that has the name of temaTeste, so it  temaTeste/config.php)

<?php

$THEME->name = 'base';
$THEME->doctype = 'html5';

$THEME->parents = array();

$THEME->sheets = array('base');

$THEME->layouts = array(
    // Most backwards compatible layout without the blocks - this is the layout used by default
    'base' => array(
        'file' => 'standard.php',
        'regions' => array(),
    ),
);



$THEME->javascripts = array();
$THEME->javascripts_footer = array();


?>



arquive standard.php (temaTeste/layout/standard.php)

<?php
$hassidepre = $PAGE->blocks->region_has_content('side-pre', $OUTPUT);
$hassidepost = $PAGE->blocks->region_has_content('side-post', $OUTPUT);
echo $OUTPUT->doctype(); ?>
<html <?php echo $OUTPUT->htmlattributes() ?>>
<head>
    <title><?php echo $PAGE->title ?></title>
    <link rel="shortcut icon" href="<?php echo $OUTPUT->pix_url('favicon', 'theme')?>" />

    <?php echo $OUTPUT->standard_head_html() ?>
</head>

<body id="<?php p($PAGE->bodyid); ?>" class="<?php p($PAGE->bodyclasses); ?>">

<?php echo $OUTPUT->standard_top_of_body_html() ?>

<table id="page">
    <tr>
        <td colspan="3">
            <h1 class="headermain"><?php echo $PAGE->heading ?></h1>
            <div class="headermenu"><?php echo $OUTPUT->login_info(); echo $PAGE->headingmenu; ?></div>
        </td>
    </tr>
    <tr>
        <td>
            <?php echo $OUTPUT->blocks_for_region('side-pre') ?>
        </td>
        <td>
            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
        </td>
        <td>
            <?php echo $OUTPUT->blocks_for_region('side-post') ?>
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <p class="helplink"><?php echo page_doc_link(get_string('moodledocslink')) ?></p>
            <?php
            echo $OUTPUT->login_info();
            echo $OUTPUT->home_link();
            echo $OUTPUT->standard_footer_html();
            ?>
        </td>
    </tr>
</table>


<?php echo $OUTPUT->standard_end_of_body_html() ?>
</body>
</html>

I need to settle it in moodle and it needs to change, it's a simple theme just for study / testing.

Average of ratings: -
In reply to A SSSS

Re: Moodle - Creating Themes / Theme Simple Study

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

What do the version.php and language files look like please?

No closing ?> at the end of PHP files.

Have you looked at how other themes are constructed?

What documentation have you read?

What version of Moodle are you creating it for?

In reply to A SSSS

Re: Moodle - Creating Themes / Theme Simple Study

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

temaTeste/config.php

need to be all lower case letter such as themteste

The config is also wrong too. The theme name is NOT 'base' it should read 'temateste' like so...

<?php

$THEME->name = 'temeteste';
$THEME->doctype = 'html5';

$THEME->parents = array('');

$THEME->sheets = array('base');

$THEME->layouts = array(
    // Most backwards compatible layout without the blocks - this is the layout used by default
    'base' => array(
        'file' => 'standard.php',
        'regions' => array(),
    ),
);

In reply to Mary Evans

Re: Moodle - Creating Themes / Theme Simple Study

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

I presume your css file is called base.css?

Personally, I would recommend adding a parent theme (probably base)

$THEME->parents = array('base');
because at the moment, with no parent theme, you have none of the layout files declared other than the base one, and if as you say your css file is empty, then you have no css to fall back to either. If you declare a parent theme, then your theme can fall back to the layout files used in the parent, but without any parent, I don't think it will work as there are no layout files declared anywhere (@Mary or @Gareth - would Moodle fall back to the base layout for other page layouts if none are declared ie there is no parent, even base/bootstrapbase? I don't think it would, but haven't specifically tested that. EDIT: just tried in a Moodle3 site by removing the layout files from bootstrapbase config.php and selecting that as the theme - error messages, but the page is there so must be picking up the base layout, I guess). Hmmm, OK.

As well as the Main Content token changing that Mary has already mentioned, from somewhere around Moodle 2.2 or 2.3 a version.php became a required file in the setup of your theme and your theme will not install without it.

If you are using such an old version of Moodle as 2.0 or 2.1, please see https://docs.moodle.org/dev/Creating_a_theme for instructions

If you are using a newer version (bearing in mind that Moodle is now at v.3 and even 2.7LTS is only security fixes now), then please see https://docs.moodle.org/dev/Clean_theme, or the readme file in the Clean theme itself.

TBH if you are using something as old as 2.0 or 2.1 then I would ask the question 'why?' If the purpose of your theme is for testing and studying, surely you should be looking at an upto date version of Moodle and how themes work in that.

Richard

In reply to Richard Oelmann

Re: Moodle - Creating Themes / Theme Simple Study

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Personally Richard I think this is a wind up...so don't lose sleep over it.

In reply to A SSSS

Re: Moodle - Creating Themes / Theme Simple Study

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Following on from my last comment...

I assume you are using Moodle 2.1 or older as the layout main content TOKEN changed in Moodle 2.2

From this...

https://github.com/moodle/moodle/blob/MOODLE_21_STABLE/theme/base/layout/frontpage.php#L56

to this...

https://github.com/moodle/moodle/blob/MOODLE_22_STABLE/theme/base/layout/frontpage.php#L56