CMS Development

shivammishra
Teilnehmer/-in

http variables in template

I am trying to use request.headers variable in hubspot page templates but it gives me a white death screen once I try to print it.

At some instances, it does work but most of the time page just crashes when I use this variable in template.

I am confused if its related to cache.

0 Upvotes
7 Antworten
shivammishra
Teilnehmer/-in

http variables in template

I am not sure if I understand which module are you referring to as I am using this variable in a template and not in a module.

0 Upvotes
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

http variables in template

@shivammishra , could you send to me a link to the template.  I don't think the community will be able to help with this one. 

0 Upvotes
shivammishra
Teilnehmer/-in

http variables in template

well I got that from the documentation but problem is that using {{ request.headers|pprint }} in templates causing pages to crash resulting in white screen of death.

0 Upvotes
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

http variables in template

@shivammishra , could you point me at the module in question?

0 Upvotes
shivammishra
Teilnehmer/-in

http variables in template

Well I am trying to just print headers right now, but I actually want to use one of the headers in if condition to display some blocks from template which is behaving very weird (end up giving the same white screen of death at page) in design manager when I try to use request.headers or request.cookies variables in a if condition inside a template.

 

{{ request.headers }} {% if request.headers['some-header'] %}

{% block header %} {% global_partial path='../partials/header-no-navigation.html' %} {% endblock header %}{% block body %} {% endblock body %}

{% endif %}

dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

http variables in template

@shivammishra 

You should be able to see all available variables in that dict by using the pretty print option

Like this {{ request.headers|pprint }}

You would call the specific variable like this {{ request.headers.cookie }}

Do keep in mind that using request.headers will disable caching on your page

0 Upvotes
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

http variables in template

Hey @shivammishra 

Would you mind dropping your code here so we can see exactly what you are doing? 

@alyssamwilie or @dbeau79 might be able to help 😀

0 Upvotes