DokuWiki

It's better when it's simple

User Tools

Site Tools


template:twigstarter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
template:twigstarter [2021-07-14 16:07] anditemplate:twigstarter [2023-01-10 18:49] (current) – version upped andi
Line 5: Line 5:
 author        : Andreas Gohr author        : Andreas Gohr
 email         : andi@splitbrain.org email         : andi@splitbrain.org
-lastupdate_dt : 2020-07-07+lastupdate_dt : 2022-09-30
 compatible    : compatible    :
 depends       : depends       :
Line 28: Line 28:
  
 DokuWiki expects three files in a template directory: ''main.php'', ''detail.php'' and ''mediamanager.php''. When you look at these files in twigstarter you will notice that all three files are the same and simply initialize a namespaced TemplateController class defined in ''TemplateController.php''. DokuWiki expects three files in a template directory: ''main.php'', ''detail.php'' and ''mediamanager.php''. When you look at these files in twigstarter you will notice that all three files are the same and simply initialize a namespaced TemplateController class defined in ''TemplateController.php''.
 +
 +
 +> There's also a [[https://www.patreon.com/posts/combining-twig-27328611|blog post]] available giving a bit more background information.
  
 Depending on what way you want to use, there are different things to do: Depending on what way you want to use, there are different things to do:
Line 37: Line 40:
 ==== TwigStarter Child ==== ==== TwigStarter Child ====
  
-If you want to depend on the original twigstarter template, copy over all files except for+If you want to depend on the original twigstarter template, copy over the following files:
  
-  * ''TemplateController.php'' +  * ''main.php'' 
-  * ''vendor/'' +  * ''detail.php'' 
-  * ''composer.json'' +  * ''mediamanager.php'' 
-  * ''composer.lock'' +  * ''style.ini''
-  * ''templates/''+
  
 Next create your own ''templates'' directory and start writing the templates you want. Next create your own ''templates'' directory and start writing the templates you want.
Line 73: Line 75:
   * ''<head>''   * ''<head>''
     * contains the title, meta infos and favicon setup     * contains the title, meta infos and favicon setup
-  * ''<div id="dokuwiki__top">''+  * ''%%<div id="dokuwiki__top">%%''
     * contains (nearly) everything     * contains (nearly) everything
     * has the ''dokuwiki'' class (and others) set -- many plugins do require a div.dokuwiki at toplevel     * has the ''dokuwiki'' class (and others) set -- many plugins do require a div.dokuwiki at toplevel
Line 119: Line 121:
  
 Note: Twig escapes by default, when you call functions that return HTML you need to pass them through the ''raw'' filter! Note: Twig escapes by default, when you call functions that return HTML you need to pass them through the ''raw'' filter!
 +
 +==== Custom Controller ====
  
 Usually you want some additional PHP code in your template. The easiest way to do so is to create class ''\dokuwiki\template\YOURTEMPLATE\CustomController'' that implements the ''\dokuwiki\template\twigstarter\CustomControllerInterface''. This class will automatically be instantiated and be made available as the variable ''SELF'' in Twig. Usually you want some additional PHP code in your template. The easiest way to do so is to create class ''\dokuwiki\template\YOURTEMPLATE\CustomController'' that implements the ''\dokuwiki\template\twigstarter\CustomControllerInterface''. This class will automatically be instantiated and be made available as the variable ''SELF'' in Twig.
 +
  
 ==== Caching and Debugging ==== ==== Caching and Debugging ====
template/twigstarter.1626271675.txt.gz · Last modified: 2021-07-14 16:07 by andi

Except where otherwise noted, content on this wiki is licensed under the following license: 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