DokuWiki

It's better when it's simple

Herramientas de usuario

Herramientas del sitio


es:devel:templates
no way to compare when less than two revisions

Diferencias

Muestra las diferencias entre dos versiones de la página.


Revisión previa
Próxima revisión
es:devel:templates [2013-04-28 07:14] polypus
Línea 1: Línea 1:
 +====== Desarrollo de Plantilla DokuWiki ======
  
 +Puedes personalizar el diseño de [[:DokuWiki]] creando una nueva plantilla. Una plantilla se determina por algunos archivos PHP y CSS almacenados en el directorio apartado de la ''<dokuwiki>/lib/tpl/'' carpeta. (En realidad, la plantilla esta realizada en HTML, el PHP se utiliza para insertar contenido.)
 +
 +===== Introducción =====
 +
 +La mejor manera de hacer una plantilla es a partir de una ya existente como punto de partida. Es una buena idea es utilizar la pantilla [[template:starter]] porque es limpia y se ajusta a los estandares de DokuWiki. 
 +
 +Los nombres de las plantillas deben estar en minuscula (carpeta), y no deben contener "." (punto) O "_" (guión bajo) dado que no estan permitidos.
 +
 +  - Instalar la plantilla Starter
 +  - Renombre la carpeta ''lib/tpl/starter'' al nombre que usted desee ''lib/tpl/SuNOMBRE''
 +  - Seleccione la nueva plantilla con el gestor de configuración.
 +  - A continuacion eche un vistazo a los archivos de su plantilla (ver [[#directory layout]] mas abajo)
 +  - Vea que que en [[:DokuWiki]] se maneja un [[devel:css|CSS]] utilizando su [[devel:css|CSS dispatcher]].
 +  - Handling of configuration settings is analogous to [[common_plugin_functions|plugins]]. Use ''%%tpl_getConf(<setting>)%%'' to retrieve custom template settings.
 +
 +===== Directory Layout =====
 +
 +Templates should follow the following directory structure (all paths are relative to the template directory). 
 +
 +CSS files are specified in the ''[[CSS#style.ini]]'' file. Use as many files you'd like, but you should at least provide one CSS file for the screen presentation and one for printing.
 +
 +  * ''<dokuwiki>/lib/tpl/<template>/''
 +    * ''<filename>.css''
 +    * ''[[devel:templates:main.php]]'' -- general layout of DokuWiki
 +    * ''[[devel:templates:detail.php]]'' -- the image detail page
 +    * ''[[devel:templates:mediamanager.php]]'' -- the media-selection popup
 +    * ''images/'' -- all images used in the template
 +    * ''conf/''
 +      * ''default.php'' -- [[configuration#default settings]] (see ''[[#tpl_getConf]]'')
 +      * ''metadata.php'' -- [[configuration#configuration metadata]] (see ''[[#tpl_getConf()]]'')
 +    * ''lang/'' -- language files
 +      * ''<lang code>/lang.php'' -- localization strings used in the template
 +      * ''<lang code>/settings.php'' -- localization strings used in the configuration manager
 +    * ''style.ini'' -- see [[CSS#Style.ini]]
 +    * ''favicon.ico'' -- will be used if none exists in the media-directory (see [[xref>tpl_getFavicon()|tpl_getFavicon()]])
 +    * ''template.info.txt'' -- A text file with [[devel:template info|template information]] **required!**
 +===== Functions =====
 +
 +A list of available functions can be found in [[xref>inc/template.php|API documentation]]. Some specialties are listed here.
 +
 +  * **''[[xref>tpl_content()]]''** \\ This function outputs the page body, or in other words the content of your wiki page, including the [[:TOC]]. You can prevent it from outputting the TOC by passing ''false'' while calling it: <code php>
 +tpl_content(false);
 +</code>This can be used to separate the TOC from the content and place it somewhere else on the screen. See ''tpl_toc()'' below for further details.
 +
 +  * **''[[xref>tpl_toc()]]''** \\ By default, the ''tpl_content()'' function will take care of displaying a [[:TOC|Table of Contents]] itself, prepending it to the actual page content. If your template uses a sidebar or other more complex layout you may want to place the TOC independently from the page content. This can be done with the ''tpl_toc()'' function. When using it, it is important to disable automatic TOC placement by passing the argument ''false'' to the ''tpl_content()'' function.\\ \\ **Example:** \\ <code php>
 +<div id="content">
 +    <?php tpl_content(false)?>
 +</div>
 +
 +<div id="sidebar">
 +    <?php tpl_toc()?>
 +</div>
 +</code>The ''tpl_toc()'' function renders the TOC from three different sources: a global [[environment#$TOC]] variable, the page [[metadata]] or the ''getTOC()'' method of [[admin plugins]]. Because there is no metadata available for old revisions or preview ''tpl_toc()'' can only use the global [[environment#$TOC]] variable for these cases. Because the [[environment#$TOC]] variable is filled by the page renderer this will only work when ''tpl_toc()'' is called **after** ''tpl_content()''. If this is not possible in your template layout you may use output buffering to circumvent the problem. \\ \\ **Example:**\\ <code php>
 +<?php
 +    // render the content into buffer for later use
 +    ob_start();
 +    tpl_content(false);
 +    $buffer = ob_get_clean();
 +?>
 +
 +<div id="sidebar">
 +    <?php tpl_toc()?>
 +</div>
 +
 +<div id="content">
 +    <?php echo $buffer?>
 +</div>
 +</code>
 +
 +  * **''[[xref>tpl_getConf()]]''** \\ This function is used to access [[configuration|configuration settings]] from within the template.
 +
 +===== Global Variables And Constants =====
 +For a complete list of useful global variables and constants please refer to the [[environment]] page.
 +
 +===== Automated Housekeeping =====
 +
 +Almost at the bottom of the default template's [[devel:templates:main.php]] file you'll see a function call to ''tpl_indexerWebBug()''. The function generates a HTML ''%%<img>%%'' tag which results in a request to ''[[:indexer|lib/exe/indexer.php]]''. This **vital** part of DokuWiki provides important housekeeping work to keep the wiki running smoothly. All templates should include this function, without it the wiki may not function correctly (for example the [[:search|search index]] wont be built).
 +
 +===== 'dokuwiki' class =====
 +
 +A class named ''dokuwiki'' should be added to some content surrounding element (either around everything or at least around ''tpl_content()'') in each template's main.php, detail.php and mediamanager.php. This is to make sure that DokuWiki's styles don't interfere with other styles if it gets integrated into an existing site with potentially conflicting CSS.
 +
 +===== Include Hooks =====
 +
 +Include Hooks are a simple way to add some static content to your [[:DokuWiki]] installation without writing your own [[:Template]]. You can use them for adding a standard header or company logo to each page or add a disclaimer at the bottom of each page.
 +
 +The DokuWiki's default template looks for files with special names in the template directory and simply includes them at the correct places when displaying the page. You can add whatever HTML you like into these files. Of course this only works if you are using the //default// template or a template supporting the same include hooks (like the starter template).
 +
 +__Hint for PHP developers:__ You may be happy to hear that you can even include PHP in these files.
 +
 +==== Available Hooks ====
 +
 +All these files are searched for in the ''lib/tpl/default/'' directory.
 +
 +^ Filename        ^ Position of included HTML                                                ^
 +| ''meta.html''       | Inside the HTML <head>, use this to add additional styles or metaheaders |
 +| ''topheader.html''  | At the very top of the page right after the <body> tag |
 +| ''header.html''     | Above the upper blue bar, below the pagename and wiki title |
 +| ''pageheader.html'' | Below the breadcrumbs, above the actual content |
 +| ''pagefooter.html'' | Above the lower blue bar, below the last changed Date |
 +| ''footer.html''     | At the very end of the page just before the </body> tag |
 +
 +DokuWiki comes with an example ''footer.html'' containing some buttons and a CC license RDF description.
 +
 +See also [[:include hooks]] for the user explanation.
es/devel/templates.txt · Última modificación: 2014-07-21 10:57 por 82.158.57.250

Excepto donde se indique lo contrario, el contenido de este wiki esta bajo la siguiente licencia: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki