HS Redirect
ExpressionEngine 2
Back to this add-on's main page
View Other Add-ons From Kevin Smith
Redirect Not Working
General
Brett DeWoody
|
Posted: 18 January 2011 11:14 PM |
|
|
|
I’m trying to redirect a template based on a custom field. The custom field contains a full URL and my template looks like this:
{exp:channel:entries} {exp:hs_redirect location="{redirect-url}"} {/exp:channel:entries}
Unfortunately it’s not redirecting to the URL. It’s just loading the template.
If I put anything else into the template (like {redirect-url}) it will spit that out on the page. Am I misunderstanding how this plugin works?
|
|
|
Kevin Smith
|
Posted: 20 January 2011 03:24 AM |
# 1
|
|
Developer
|
Hmm… I think the problem has to do with the parse order. Lowe created a great PDF for a talk at EECI2010 that I keep posted next to my computer that details the order in which EE parses variables, tags, etc. Check it out: http://loweblog.com/downloads/ee-parse-order.pdf
To get at your question specifically, I’m guessing {redirect-url} is a user-defined global variable? Or is it created using preload_replace?
|
|
|
Brett DeWoody
|
Posted: 20 January 2011 05:24 PM |
# 2
|
|
|
{redirect_url} is a custom variable (defined on the publish entry page) that contains an absolute URL.
So if I do something like this:
{exp:channel:entries} {redirect-url} {exp:hs_redirect location="{redirect-url}"} {/exp:channel:entries}
The URL will be displayed on the page, but the redirect doesn’t work.
Is there a way to use a custom variable in the location parameter?
|
|
|
Kevin Smith
|
Posted: 20 January 2011 05:59 PM |
# 3
|
|
Developer
|
For the sake of troubleshooting, if you replace the custom field tag {redirect-url} with a static url like http://google.com and leave everything else the same, does the template redirect properly?
|
|
|
Brett DeWoody
|
Posted: 20 January 2011 06:01 PM |
# 4
|
|
|
Unfortunately not. My template contains just the {exp:channel:entries} loop with the {exp:hs_redirect location=“http://www.google.com”} in it.
|
|
|
Kevin Smith
|
Posted: 20 January 2011 06:05 PM |
# 5
|
|
Developer
|
Hmm… you’re using EE2, correct?
Would you mind creating a new test template with only the HS Redirect plugin’s tag in it. Something like this:
{exp:hs_redirect location="http://www.yahoo.com"}
Let me know if that goes through.
|
|
|
Brett DeWoody
|
Posted: 20 January 2011 06:14 PM |
# 6
|
|
|
EE2 - Version 2.1.3 Build 20101220
I removed the exp:channel loop so my template contains just the code you posted above. Still just goes to the template and doesn’t redirect.
Only other thing that I can think that might effect it is that I’m using Structure. So the pages where the hs_redirect is used is managed by Structure. Could that be responsible?
|
|
|
Kevin Smith
|
Posted: 20 January 2011 06:17 PM |
# 7
|
|
Developer
|
Could be, but I don’t have a license for Structure, so I can’t test it out. I’m also not familiar with exactly how Structure modifies the core behavior of EE. Is there a way you could test it in an environment that isn’t managed by Structure. That would at least help us take a potential cause out of the equation.
|
|
|
Brett DeWoody
|
Posted: 20 January 2011 06:26 PM |
# 8
|
|
|
I just created a new template (called ‘test’) and it contains:
{exp:hs_redirect location="http://www.yahoo.com"}
But it still doesn’t process the redirect. If I put some filler text into the template that displays just fine, so I’m positive I’m hitting the correct template. When I remove the filler text a blank page appears and the redirect doesn’t happen.
Thanks for all the help!
|
|
|
Kevin Smith
|
Posted: 20 January 2011 06:32 PM |
# 9
|
|
Developer
|
No problem! This is so strange. What version PHP are you running under?
Just to try to circumvent a potential problem with PHP, try adding the script parameter to your test template.
{exp:hs_redirect method="script" location="http://www.yahoo.com"}
That’ll use Javascript as the method for redirection instead. Might help us narrow down the problem.
|
|
|
Brett DeWoody
|
Posted: 20 January 2011 06:35 PM |
# 10
|
|
|
Nope…. still just returns the template, with no redirect.
Sorry for all this trouble. If you don’t have time to support I can dive into the plugin and try to debug myself.
|
|
|
Kevin Smith
|
Posted: 20 January 2011 06:37 PM |
# 11
|
|
Developer
|
I’ve got a little free time today, no worries. What version PHP?
|
|
|
Kevin Smith
|
Posted: 20 January 2011 06:42 PM |
# 12
|
|
Developer
|
Btw, with the script method, it should actually be outputting javascript code to your HTML source, so you should be able to see it. Does it show up in the HTML page source?
|
|
|
Brett DeWoody
|
Posted: 20 January 2011 08:40 PM |
# 13
|
|
|
The source is completely blank. Does it require that I have a <header> on the page? Cause right now the template is just the {exp:hs_redirect location=“http://www.yahoo.com”} tag and nothing else.
|
|
|
Kevin Smith
|
Posted: 20 January 2011 08:47 PM |
# 14
|
|
Developer
|
No, just the tag alone should do it. So that means the plugin isn’t outputting anything. Hmm… I wonder if something in the 2.1.3 update caused the plugin to break. Let me investigate a bit.
|
|
|
Brett DeWoody
|
Posted: 20 January 2011 09:02 PM |
# 15
|
|
|
Sorry, PHP version is 5.2.14.
|
|
|