Skip to content

Instantly share code, notes, and snippets.

@jdeagle
Created July 9, 2015 18:33
Show Gist options
  • Save jdeagle/82db6701aaf3e3b1d997 to your computer and use it in GitHub Desktop.
Save jdeagle/82db6701aaf3e3b1d997 to your computer and use it in GitHub Desktop.
Query dependant timber rendering
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);
{% extends page_layout %}
{% block content %}
{{posts}} // partial
{% endblock %}
{% 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