Skip to content

Commit b6de826

Browse files
authored
Add docs on theme.controller setting (simplesamlphp#1026)
* Update simplesamlphp-theming.md * Add theme.controller config setting
1 parent f820765 commit b6de826

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

config-templates/config.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,15 @@
792792
*/
793793
//'theme.header' => 'SimpleSAMLphp'
794794

795+
/**
796+
* A template controller, if any.
797+
*
798+
* Used to intercept certain parts of the template handling, while keeping away unwanted/unexpected hooks. Set
799+
* the 'theme.controller' configuration option to a class that implements the
800+
* \SimpleSAML\XHTML\TemplateControllerInterface interface to use it.
801+
*/
802+
//'theme.controller' => '',
803+
795804
/*
796805
* Templating options
797806
*

docs/simplesamlphp-theming.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ You can put resource files within the www folder of your module, to make your mo
9999
```
100100
modules
101101
└───mymodule
102+
└───lib
102103
└───themes
103104
└───www
104105
└───logo.png
@@ -130,6 +131,13 @@ If you need to make more extensive customizations to the base template, you shou
130131

131132
Any references to `$this->data['baseurlpath']` in old-style templates can be replaced with `{{baseurlpath}}` in Twig templates. Likewise, references to `\SimpleSAML\Module::getModuleURL()` can be replaced with `{{baseurlpath}}module.php/mymodule/...`
132133

134+
Even more advanced changes can be made by defining a theme controller in `config.php`:
135+
136+
'theme.controller' => '\SimpleSAML\Module\mymodule\FancyThemeController',
137+
138+
This requires you to implement `\SimpleSAML\XHTML\TemplateControllerInterface.php` in your module's `lib`-directory.
139+
The class can then modify the Twig Environment and the variables passed to the theme's templates. In short, this allows you to set additional global variables and to write your own Twig filters and functions.
140+
133141
See the [Twig documentation](https://twig.symfony.com/doc/1.x/templates.html) for more information on using variables and expressions in Twig templates, and the SimpleSAMLphp wiki for [our conventions](https://github.com/simplesamlphp/simplesamlphp/wiki/Twig-conventions).
134142

135143
The wiki also includes some information on [migrating translations](https://github.com/simplesamlphp/simplesamlphp/wiki/Migrating-translation-in-Twig) and [migrating templates](https://github.com/simplesamlphp/simplesamlphp/wiki/Twig:-Migrating-templates).

0 commit comments

Comments
 (0)