Low Variables Fieldtype & PHP Redirect Template
I'm running a Structure-managed site and have a couple of "pages" in the navigation that link straight to the client's social media sites.
Using this technique, I set up an external redirect template and added a Low Variables fieldtype for my "social media" LV group. The LV field is named "external_link".
Here's my redirect template code:
<?php
header( "Location: {exp:channel:entries channel='external_link'}{exp:low_variables:single var='{external_link}'}{/exp:channel:entries}" );
exit;
?>
But that outputs a blank template.
If I take out the PHP code and just run a channel entries loop:
{exp:channel:entries channel='external_link'}
<p>{exp:low_variables:single var='{external_link}'}</p>
{/exp:channel:entries}
This outputs paragraph tags but nothing inside.
{exp:channel:entries channel='external_link'}
<p>{external_link:var}</p>
{/exp:channel:entries}
This outputs the correct variable data (a URL to Twitter).
But this:
<?php
header( "Location: {exp:channel:entries channel='external_link'}{external_link:var}{/exp:channel:entries}" );
exit;
?>
Gives me the error: "The URI you submitted has disallowed characters." and the page URL changes to http://mysite.com/contact/%7Blv_twitter%7D
So I'm stumped.
Replies
Low 1 Jul 2012 11:23
I reckon the below code should work, if you've got PHP on Output and the {external_link} var is the name of the custom channel field (the LV fieldtype):
If it doesn't, enable template debugging and look up the lines that mention Low Variables and post those here.
kgrote 1 Jul 2012 14:50
Nope, doesn't work - blank screen.
Nothing happens when I enable template debugging. Blank screen again!
And yes, I have the template set to PHP on Output.
Low 1 Jul 2012 20:10
Okay, that would imply a suppression of a php error.
Can you give me superadmin access to your installation? If so, you can send the login credentials to hi at gotolow dot com.
Low 2 Jul 2012 15:59
Turned out it was a VZ URL / Low Variables quirk. I've patched the fieldtype (and Eli's mentioned he's going to add it to his add-on), so now it works correctly.