devel:templates
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
devel:templates [2010-02-18 11:49] – itself is one word 194.66.175.81 | devel:templates [2020-04-07 20:23] – desbest | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== DokuWiki Template Development ====== | ====== DokuWiki Template Development ====== | ||
- | You can customize the design of [[: | + | You can customize the design of [[: |
===== Getting Started ===== | ===== Getting Started ===== | ||
- | The easiest way to create a new template is by taking an already existing one as starting point. It's a good idea to use the default template because it is clean and follows the DokuWiki template standards. Template names (directories) have to be lowercase, " | ||
- | | + | The easiest way to create a new template is by taking an already existing one as starting point. It's a good idea to use the starter template because it is clean and follows the DokuWiki template standards. |
+ | |||
+ | - Install the [[template: | ||
+ | | ||
- Select the new template in the configuration manager | - Select the new template in the configuration manager | ||
- | - Then have a look at the template files (see [[#Directory Layout]]) | + | - Then change your template to your heart' |
- | - Have a look on how [[:DokuWiki]] handles | + | - When your template is ready, consider |
- | | + | |
+ | ===Template naming conventions=== | ||
+ | |||
+ | A valid template name (directory): | ||
+ | * Should only contain the characters a-z and 0-9. | ||
+ | * Dot '' | ||
+ | * DokuWiki' | ||
+ | * Using underscore will also give a [[:popularity|popularity]] rating of zero. | ||
+ | | ||
+ | * they are mutually exclusive and inherent incompatible, | ||
+ | * furthermore only one of them can have a template homepage on dokuwiki.org. | ||
+ | |||
+ | **It is important | ||
===== Directory Layout ===== | ===== Directory Layout ===== | ||
- | The templates | + | |
+ | Templates | ||
+ | |||
+ | CSS files are specified in the '' | ||
* ''< | * ''< | ||
- | * ''< | + | * ''< |
+ | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
* '' | * '' | ||
- | * ''< | + | * ''< |
- | * ''< | + | * ''< |
- | * '' | + | * '' |
+ | * '' | ||
+ | * '' | ||
- | ===== Functions ===== | + | Handling of configuration settings is analogous to [[common_plugin_functions|plugins]]. Use '' |
- | A list of available functions can be found in [[http:// | ||
- | ==== tpl_content() | + | ===== Inner workings explained ===== |
- | 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 '' | + | |
- | <code php> | + | ==== Functions ==== |
- | tpl_content(false); | + | |
- | </ | + | |
- | This can be used to separate the TOC from the content and place it somewhere else on the screen. See '' | + | A list of available functions |
- | ==== tpl_toc() ==== | + | * **'' |
- | + | tpl_content(false); | |
- | By default, the '' | + | </ |
- | **Example: | + | * **'' |
- | + | ||
- | <code php> | + | |
<div id=" | <div id=" | ||
<?php tpl_content(false)?> | <?php tpl_content(false)?> | ||
Line 55: | Line 70: | ||
<?php tpl_toc()?> | <?php tpl_toc()?> | ||
</ | </ | ||
- | </ | + | </ |
- | + | ||
- | The '' | + | |
- | + | ||
- | **Example: | + | |
- | + | ||
- | <code php> | + | |
<?php | <?php | ||
// render the content into buffer for later use | // render the content into buffer for later use | ||
Line 78: | Line 87: | ||
</ | </ | ||
- | ==== tpl_getConf() | + | * **'' |
- | This function is used to access [[configuration|configuration settings]] from within the template. | + | |
- | ===== Global Variables And Constants | + | * **'' |
+ | |||
+ | * Further many other useful template functions are available. Please have a look in [[xref> | ||
+ | |||
+ | ==== Global Variables And Constants ==== | ||
For a complete list of useful global variables and constants please refer to the [[environment]] page. | For a complete list of useful global variables and constants please refer to the [[environment]] page. | ||
- | ===== Automated Housekeeping ===== | + | ==== Automated Housekeeping ==== |
+ | |||
+ | Almost at the bottom of the default template' | ||
+ | |||
+ | ==== ' | ||
+ | |||
+ | A class named '' | ||
+ | |||
+ | ==== Include Hooks ==== | ||
+ | |||
+ | Include Hooks are a simple way to add some static content to your [[: | ||
+ | |||
+ | The DokuWiki' | ||
+ | |||
+ | ===== Converting existing templates ===== | ||
+ | |||
+ | If you're lacking design skills you can also convert existing templates. There are lots of free options available. If you'd like to publish one of those as well, please make sure it is [[https:// | ||
+ | |||
+ | * [[WP_to_DW_template|How to convert a WordPress theme to a DokuWiki template]] | ||
+ | |||
+ | ===== Avoiding problems ===== | ||
+ | |||
+ | Here are a few problems template developers run into and how to avoid them: | ||
+ | |||
+ | ===Don' | ||
+ | This includes '' | ||
- | Almost at the bottom of the default | + | ===Turn off " |
- | ===== ' | + | Some template developers experience problems with DokuWiki cacheing CSS and JS files due to this option being on, although this has been hard to pinpoint. To be safe, turn this off temporarily. |
- | A class named '' | + | ===Use " |
+ | You can accomplish this by pressing Ctrl+F5 | ||
- | ===== Include Hooks ===== | + | This is not due to how DokuWiki works, but how current browsers cache files. Browsers cache stylesheets even when new versions are available, so you will need to do this. |
- | Include Hooks are a simple way to add some static content to your [[: | + | ===== Publishing |
- | DokuWiki' | + | If you created a template, please share it with the community. Just create a page named after your template |
- | __Hint for PHP developers: | + | The page should contain all needed documentation on how to install and use the template. Adding screenshots might be a good idea as well. |
- | ==== Available Hooks ==== | + | At the top of the template page a few metadata fields have to be filled in. A description of each field can be found on the [[plugin: |
- | All these files are searched for in the ''lib/tpl/ | + | From version Ponder Stibbons on an automated update signalling is possible. For the update process to work properly it is necessary that the date “Last updated on” on the template's wiki page equals the date in the file [[devel: |
- | ^ Filename | + | Uploads are not allowed on dokuwiki.org, so you need to host your template files somewhere else. We recommend to manage your source with a Revision Control System like [[git]]. If you do, it's easiest to use a public repository host like [[https:// |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | DokuWiki comes with an example | + | ===== See Also ===== |
+ | If you are converting a wordpress theme to a dokuwiki template, it's worth looking at [[devel: |
devel/templates.txt · Last modified: 2023-09-24 01:08 by Klap-in