Created
July 9, 2015 18:33
-
-
Save jdeagle/82db6701aaf3e3b1d997 to your computer and use it in GitHub Desktop.
Query dependant timber rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InspirationModule | |
{ | |
public $template; | |
public $query; | |
public $vars; | |
} | |
$moduleA = new InspirationModule(); | |
$moduleA->template = "moduleA.twig"; | |
$moduleA->vars = queryVars as array or any other layout dependant vars you need... | |
$moduleB = new InspirationModule(); | |
$moduleB->template = "moduleA.twig"; | |
$moduleB->vars = queryVars as array or any other layout dependant vars you need... | |
$templates = [ | |
0 => moduleA, | |
1 => moduleB | |
]; | |
$nextTemplate = templates[0]; | |
Timber::load_template($nextTemplate->template, $nextTemplate->vars); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends page_layout %} | |
{% block content %} | |
{{posts}} // partial | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends page_layout %} | |
{% block content %} | |
{{posts}} // partial | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment