Creating Custom Themes

Creating Custom Themes

by Davy davy_yg -
Number of replies: 2

Hallo,

I am trying to create a custom theme:

 

excitement:

- layout :  standard.php, theme_standard.php

- pix : background.jpg, screenshot.jpg

- style  : excitement.css

config.php, version.php

 

And this is the file content:

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() ?>
<div id="page">
<?php if ($PAGE->heading || (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar())) { ?>
    <div id="page-header">
        <?php if ($PAGE->heading) { ?>
        <h1 class="headermain"><?php echo $PAGE->heading ?></h1>
        <div class="headermenu"><?php
            echo $OUTPUT->login_info();
            if (!empty($PAGE->layout_options['langmenu'])) {
                echo $OUTPUT->lang_menu();
            }
            echo $PAGE->headingmenu
        ?></div><?php } ?>
        <?php if (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar()) { ?>
            <div class="navbar clearfix">
                <div class="breadcrumb"><?php echo $OUTPUT->navbar(); ?></div>
                <div class="navbutton"> <?php echo $PAGE->button; ?></div>
            </div>
        <?php } ?>
    </div>
<?php } ?>
 
    <div id="page-content">
        <div id="region-main-box">
            <div id="region-post-box">
                <div id="region-main-wrap">
                    <div id="region-main">
                        <div class="region-content">
                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
                        </div>
                    </div>
                </div>
                <?php if ($hassidepre) { ?>
                <div id="region-pre">
                    <div class="region-content">
                        <?php echo $OUTPUT->blocks_for_region('side-pre') ?>
                    </div>
                </div>
                <?php } ?>
 
                <?php if ($hassidepost) { ?>
                <div id="region-post">
                    <div class="region-content">
                        <?php echo $OUTPUT->blocks_for_region('side-post') ?>
                    </div>
                </div>
                <?php } ?>
            </div>
        </div>
    </div>
 
    <?php if (empty($PAGE->layout_options['nofooter'])) { ?>
    <div id="page-footer" class="clearfix">
        <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();
        ?>
    </div>
    <?php } ?>
</div>
<?php echo $OUTPUT->standard_end_of_body_html() ?>
</body>
</html>

 

I have zipped the excitement file (excitement.zip) and upload it in plugin - themes:

 

Validation failed!Help with Validation failed!
StatusMessageInfo
Error Invalid structure of the ZIP package.Help with Invalid structure of the ZIP package  

 

What's wrong?  Please help.

Thanks before.

Average of ratings: -
In reply to Davy davy_yg

Re: Creating Custom Themes

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

Hi,

I am getting warning bells ringing in my ears!

I guess you were using a very old theme tutorial which is only valid up to and including Moodle 2.1.

If you are trying to upload it to Moodle 2.5 and above using the upload zip option, then it will fail. Not so much the layout although the MAIN_CONTENT_TOKEN has changed...

from this...

<?php echo core_renderer::MAIN_CONTENT_TOKEN ?>

to this...

<?php echo $OUTPUT->main_content(); ?>

but mainly because it is also missing the version.php file which is needed to verify the theme that is to be installed, which needs this code...

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>;.

/**
 * Theme version info
 *
 * @package    theme_excitement
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

defined('MOODLE_INTERNAL') || die;

$plugin->version   = 2014041400; // The current module version (Date: YYYYMMDDXX)
$plugin->requires  = 2013050100; // Requires this Moodle version
$plugin->component = 'theme_excitement'; // Full name of the plugin (used for diagnostics)
$plugin->dependencies = array(
    'theme_base'  => 2013050100,
);

Hope this explains it all?  If you are not sure or still having problems please ask again.

Thanks

Mary

In reply to Mary Evans

Re: Creating Custom Themes

by Davy davy_yg -

 

I already change apart of standard.php file to:

<?php // echo core_renderer::MAIN_CONTENT_TOKEN ?>
          <?php echo $OUTPUT->main_content(); ?>

and replace all the version.php with the above file.

and when I try to upload my zip file to moodle 2.6:

 

Validation failed!Help with Validation failed!
StatusMessageInfo
Error Invalid structure of the ZIP package.Help with Invalid structure of the ZIP package