Moodle - Creating Themes

Asked

Viewed 1,624 times

0

Hi, I’m creating a theme for Moodle and I can’t install it or do tests, the theme has only 3 files and the . css is blank, just for testing...


config.php file (is at the root of the theme that has the name temaTeste, so it is 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();


?>


standard.php file (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 install it in the Moodle and it needs to run, it is a simple theme just for study/test.

  • 1

    Does the documentation say anything about where these files should be? or how they are uploaded?

  • Dude, the documentation is very confusing and I couldn’t figure out how to use hardcoded Blocks, I need examples and I didn’t find there!

1 answer

2

Below a brief step by step how to create a basic Thema for Moodle in version 2.0 onwards.

Step by step:

  1. Download the Moodle installation package http://moodle.org;

  2. Perform the extraction of the files;

  3. Navigate to the directory /theme/clean, then copy all your content and paste it into the directory /theme/seu_diretorio_do_tema_moodle. For the purpose of this step by step I will call the theme cleantheme. Preferably, always use lower case letter.

  4. When opening the directory cleantheme you will find several files and directories. These are:

config.php - Where all theme settings are made. (Contains some elements that require name change).

lib.php - Where all functions for theme settings are found. (Contains some elements that require name change);

settings.php- Where all the settings for this theme are created. (Contains some elements that require name change);

version.php - Where the version number and the information from theme type component are maintained. (It contains some elements that require name change);

/lang/ - This folder contains all language subdirectories in it can add translations to your theme. Ex: directory pt_br/theme_cleantheme.php ;

/lang/en/ This subdirectory contains the language files, in this case English;

/lang/en/theme_cleantheme.php - This file contains all strings language for your theme. (Contains some elements that need to change the name as well as the name itself);

/layout/ - This folder contains all layout files for this theme;

/layout/columns1.php - Layout file for a column layout (only the content);

/layout/columns2.php - Layout file for a layout of two columns (side-pre and content);

/layout/columns3.php - Layout file for a layout of three columns (side-pre, content and side-post) and on the front page;

/layout/embedded.php - File for file embedding layout as iframe, Object, Pdfs;

/layout/maintenance.php - Maintenance layout file that does not has no blocks, links or API calls with database access or interaction with caches;

/layout/secure.php - Secure layout file for 'saferbrowser' and safe window;

/style/ - This folder contains all CSS files for this theme;

/style/custom.css - This is where all the CSS settings is generated;

/pix/ - This folder contains an image of the theme itself, it also contains files as a favicon and all images used on the theme.

- Renaming the elements

Now we need to rename in all files the name 'clean' to the name of our theme which is cleanthenme. So, using the above list as a guide, we will search and change all occurrences of the theme name clean for cleantheme.

This includes the file name of the lang/en/theme_clean.php. You need to change it to theme_cleantheme.php.

Installing our theme Once all the changes in the name have been made, you can safely install the theme. If you are already connected, press the key F5 to update your browser. So your Moodle site will start the installation by presenting a screen to 'Check Plugins'. If not, then navigate to Administração > Notificações.

Once your theme is already installed successfully, you can select it and start modifying it using the custom settings page. To find it, navigate to Administração> Administração do Site> Aparência> Temas > and then click on (Cleantheme) or to the name of the theme you have renamed.

  • Thank you for your collaboration, but we do not only accept links as responses, as the link can get off and your response poor. If you can leave the code, you will be helping many other users who have the same questions.

  • Dear, updated post successfully! Please reevaluate it kindly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.