Moodle-Creating Themes

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


config file.php (it is in the root of the theme that has the name of temaTeste, then 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 file.php (theme/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 intala it in moodle and it needs to run, it's a simple theme just for Study / test.

Author: Alan PS, 2016-03-22

1 answers

Below is a brief step by step how to create a basic theme for moodle in Version 2.0 onwards.

Step by step:

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

  2. Extract the files;

  3. Navigate to the /theme/clean directory, then copy all of its contents and paste into the /theme/seu_diretorio_do_tema_moodle Directory. For the purpose of this step by step I will call the theme cleantheme. Take preference, always use lowercase.

  4. When you open the cleantheme directory 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 renaming);

version.php - where the version number and the theme type components are maintained. (contains some elements that require name change);

/lang/ - this folder contains all the subdirectories of languages, in it you can add the translations to your theme. Ex: Directory pt_br/theme_cleantheme.php ;

/lang/en/ it is 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 require change the name, as well as the name itself);

/layout/ - this folder contains all the layout files for this item;

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

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

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

/layout/embedded.php - file for file embedding layout like 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 - safe layout file for 'saferbrowser' and safe window;

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

/style/custom.css - this is where all CSS settings are generated;

/pix/ - this folder contains an image of the theme itself, it also contains files such as a favicon and all the images used don't be afraid.

- renaming the elements

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

This includes the file name of lang/en/theme_clean.php. You need to change this 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 F5 to update the browser. So your Moodle website will start the installation by displaying a screen for ' Check plugins '. If not, then navigate to Administração > Notificações.

Once your theme is already successfully installed, 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 (Cleantheme) or to the name of the theme you have renamed.

 2
Author: Léo Renis, 2016-05-03 14:57:41