Moodle - Creating Themes

0

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


config.php file (it's in the root of the theme that has the theme name, so it's themeTest / 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 (Test 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 install it in moodle and it needs to run, it's a simple theme for study / testing only.

    
asked by anonymous 22.03.2016 / 19:30

1 answer

2

Below is a brief step-by-step on how to create a basic moodle theme in version 2.0 onwards.

Walkthrough:

  • Download the moodle installation package link ;

  • Extract the files;

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

  • 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 renaming ).

         

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

         

    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   component type are maintained. ( Contains some elements that   require renaming );

         

    /lang/ - This folder contains all subdirectories of languages, in it   you can add the 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 require   change the name as well as the name itself );

         

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

         

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

         

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

         

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

         

    /layout/embedded.php - File for file embedding of   layout as 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   secure 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,   there are also files as a favicon and all images used   Do not fear.

    - Renaming the elements

    Now we need to rename in all files the name 'clean' for the name of our theme that is cleanthenme . Then, using the list above as a guide, we will 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 logged in, press the F5 key to refresh the browser. So your Moodle site will start the installation with 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 the name of the theme you have renamed.

        
    03.05.2016 / 15:33