8 – How to package the output according to a URL query string

In my node preprocessing function, I check the value of a query parameter …

$ variables['exclude_urls'] =  Drupal :: request () -> get (& # 39; exclude_urls & # 39;)

And in my model, I have …

{% if not exclude_urls%}
{% end if %}

However, this approach does not work because the node pretreat feature does not fire if nothing in the URL changes outside of the value of the "exclude_urls" parameter.

I have tried various methods to disable caching of the page. Add this to the road does not work …

no_cache: TRUE & # 39;

I've also tried using the page_cache_kill_switch parameter in my controller, but it does not work …

 Drupal :: service ("page_cache_kill_switch") -> trigger ();

Adding the query parameter to context caching does not do it either …

$ element['#cache']['contexts'][]    = & # 39; url.query_args: exclude_urls & # 39 ;;

Instead of using hook_preprocess_node, is there another way to check the value of $ _GET?[‘exclude_urls’] and passing that to the model? Should I add code to the twig model itself to check the value of "exclude_urls"? Is there a sure way to force hook_preprocess_node to fire every time? What is the usual approach to condition the display of content based on a URL query parameter so that caching does not interfere?

Update: To be clear, I've also tried the above approaches in a combined way, without success. For example, the end of my page function in my controller looks like this …

 Drupal :: service ("page_cache_kill_switch") -> trigger ();
$ element['#cache']['contexts'][]    = & # 39; url.query_args: exclude_urls & # 39 ;;
return $ element;