Clonar un tema

Saltar a: navegación, buscar
Advertencia: Esta página ya no está en uso. La información contenida en la página NO debería de verse como relevante ni confiable.

Nota: Esta es una traducción de una página de la documentación para desarrolladores (Developer docs), que se considera particularmente importante, y que en su versión original se actualiza frecuentemente. Por ello, se le recomienda que revise la página original en idioma inglés: Cloning a theme.

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Este documento describe cómo clonar un tema existente de Moodle 2. Asume que el lector tiene un cierto conocimiento de la manera en como trabajan los temas dentro de Moodle, además de un conocimiento básico sobre XHTML y CSS.

También, debido al rápido desarrollo dentro de Moodle, que resulta en un número considerable de versiones disponibles, principalmente 2.0.x, 2.1.x 2.2.x 2.3.x 2.4.x y Moodle 2.5.x es importante saber que este tutorial SOLAMENTE es válido para el tema Boxxie de Moodle, y que por lo tanto, no toma en cuenta los otros varios elementos que Uted encontrará en otras versiones de Moodle de temas como Afterburner, Formal White, Sky High, por nombrar algunos. Si Usted está buscando clonar uno de éstos temas, entonces revise los nuevos tutoriales: How to clone a Moodle 2.2 theme.


Inicio

Since this is a very easy introduction to creating a custom theme, the first thing to create is a copy of the version of the theme you want to clone. For the purpose of this tutorial, we will be cloning Boxxie, which is one of several Moodle core themes. There are other themes you can 'clone' which are a little harder to do, but once you are familiar with this easy one, you can tackle the harder ones later.

OK...let's get started. From your Moodle theme directory right click on boxxie and then copy and paste back into your Moodle theme directory. You should now have a folder called Copy of boxxie. If you right click this folder you are given the option to Rename it. So let's rename this folder to foxxie (or to whatever name you want to call your cloned theme). It is important to use only lower case letters and underscores.

If you open the foxxie directory you will find several directories, sub-directories and files within it. One of these sub-directories lang/en/ contain a file called theme_boxxie.php which will need to be re-named to theme_foxxie.php. But we shall address this later. For now just familiarise yourself with what you find in the foxxie directory.

These are:

config.php 
Where all the theme configurations are made.
/lang/ 
This directory contains all language sub-directories for other languages if and when you want to add them.
/lang/en/ 
This sub-directory contains your language files, in this case English.
/lang/en/theme_boxxie.php 
This file contains all the language strings for your theme.
/layout/ 
This directory contains all the layout files for this theme.
/layout/frontpage.php 
Layout file for front page.
/layout/general.php 
Layout file for all pages other than the front page.
/layout/embedded.php 
Layout file for embedded pages.
/style/ 
This directory contains all the CSS files for this theme.
/style/core.css 
Contains all the CSS rules for this theme.
/style/boilerplate.css 
Contains all the reset CSS rules for this theme.
/pix/ 
This directory contains a screen shot of this theme as well as a favicon and any images used in the theme.
/pix/tabs 
This contains all the tab images for this theme.

Renombrar Elementos

El problema al clonar' un tema es que Usted necesita renombrar todas aquellas instancias en donde ocurre el nombre del tema, en este caso, boxxie. El primer lugar para buscar es config.php, en donde Usted necesitará cambiar el nombre del tema.

$THEME->name = 'boxxie';
 
////////////////////////////////////////////////////
// Name of the theme. Most likely the name of
// the directory in which this file resides.
////////////////////////////////////////////////////

The next place to look, as mentioned above, is lang/en/theme_boxxie.php. This file, as well as needing to be renamed, also needs some of its content renaming too. So before we forget, let's right click on this file and rename it theme_foxxie.php before we open it.

Cadenas de texto de idioma

When you open theme_foxxie.php the first thing you will see are the credits for the theme.

/**
 * Strings for component 'theme_boxxie', language 'en', branch 'MOODLE_20_STABLE'
 *
 * @package   moodlecore
 * @copyright 2010 Patrick Malley
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

Here you will need to change the reference from boxxie to foxxie, you can leave the rest of this as it is.

The next things you will find in this file are what are known as the language strings. These are used for any customised words or phrases used in a theme. And because this is in the foxxie/lang/en/ directory all the $strings are in English. But if you wanted to add some foreign words and phrases for whenever a user switched languages, you just need to create a new sub-directory in the foxxie/lang/ directory for the language files you need to add there, and then copy and paste this file to that new sub-directory. For example: foxxie/lang/it/theme_foxxie.php (where it is the code which represents the Italian language). We will explore the Language aspect of themes in another Moodle Doc. So let's just concentrate on the changes we need to make to rest of the contents of theme_foxxie.php.

$string['pluginname'] = 'Boxxie';
$string['region-side-post'] = 'Right';
$string['region-side-pre'] = 'Left';

In the $string section above, the only thing you need to change here is the pluginname from boxxie to foxxie.

In this next section, the choosereadme, which is written in XHTML and is the contents of the page that you will see when selecting Foxxie in the Theme Selector. However, you are advised to read what is actually written there and change it accordingly, renaming 'Boxxie' to 'Foxxie', and changing the contents of this part to suit yourself. You might not want to keep all that is written here. You could actually condense it, but that's up to you. Just as long as you give credit, where credit is due, to the original theme designer by stating something on similar lines to what I have written below.

$string['choosereadme'] = 'Foxxie is a customised Moodle theme
by Mary Evans based on the original Boxxie theme by Patrick Malley';

Receta para el impaciente

Para aquellos que quieren un conjunto mínimo de instrucciones para irse semi-ciegamente a traves del procedimiento:

1. Copiar [moodleroot]/theme/boxxie a [moodleroot]/theme/foxxie


2. Renombrar [moodleroot]/theme/foxxie/lang/en/theme_boxxie.php a [moodleroot]/theme/foxxie/lang/en/theme_foxxie.php


3. En [moodleroot]/theme/foxxie/lang/en/theme_foxxie.php, remplazar cualquier instancia de la palabra "boxxie" con la palabra "foxxie", y hacer lo mismo con "Boxxie" y "Foxxie".


4. Editar [moodleroot]/theme/foxxie/config.php para remplazar las instancias de "boxxie" con "foxxie".

Apéndice

Por favor tome nota de que todos los nombres de temas, nombres de directorios y nombres de archivos DEBEN DE estar en letras minúsculas.

Vea también