0

Trying to create the following redirect template for some structure pages, however the url is outputting like this http://example.com/{site_url}#section. Any idea why {site_url} variable isn't working? And/or any idea how to resolve issue. Thanks in advance.

{exp:channel:entries channel="pages"}
    <?php
        header( "Location: {site_url}#{homepage_section}" );
        exit;
    ?>
{/exp:channel:entries}
0

You have PHP set to input on this template. That means that that something like:

<?php
    $test = "{site_url}";
?>

Causes the template parsing engine to eval the raw PHP code before replacing {site_url} with the actual site URL. You need to set PHP to output for this template, which means that EE template tags get parsed FIRST, then it evals the PHP code, meaning the above will look like this by the time the raw PHP gets executed:

<?php
    $test = "http://www.domain.com";
?>

Soooo yeah. FYI, if you have PHP on that template in other places, switching from input to output could definitely break things.

Edit

Wait.. so one EE tag is getting parsed, but the other isn't?

  • The templates are already set to output. And yes, the {homepage_section} variable is parsing, but not the global variable, {site_url}. Any idea? – frshjb373 Aug 27 '15 at 15:26

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.