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
Both sides next revision
template:twigstarter [2021-07-14 16:07]
andi
template:twigstarter [2021-11-23 10:56] (current)
andi [Variables and Functions]
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 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