1

I have this in a template:

{% import "_helpers/macros" as macros %}
{% set redirectUrl = macros.testRelatedReview(entry) %}
{% redirect redirectUrl 301 %}

The macro returns an entry URL.

But the page returns an error:

Header may not contain more than a single header, new line detected

If I change it to {% redirect 'actual_value_of_redirectUrl' 301 %}, it redirects OK.

How do I get it to work with the dynamic variable though?

2

new line detected should give you an idea of what to look for - your macro file may have some line breaks between code blocks, and it's writing them to the page before hitting your redirect tag. Try wrapping it all in {% spaceless %} tags, and see if that helps?

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.