新建block+cache
https://drupal.stackexchange.com/questions/223376/what-is-the-correct-way-to-set-cache-contexts-on-custom-blocks
---------
public function build() {
$search_form = \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\SearchForm');
return [
'#theme' => 'mycustomtemplate',
'#search_form' => $search_form,
'#cache' => ['contexts' => ['url.path', 'url.query_args']]
];
}
{% block content %}
{{ content }}
{% endblock %}
浙公网安备 33010602011771号