Hello All,
A newbie to EE, trying to implement some global and superglobal variables into templates in my EE site. Basic scenario is this:
I am trying to integrate an EE site located at subdomain.mydomain.com. The main site, mydomain.com, is an ASP.NET content-managed site. There are some variables that I need to carry over to the EE site to have links transition back out of the EE site smoothly.
Below is some PHP code (I am not a programmer, so please excuse the poor code!) that I am trying to include in my EE templates to set the variables that I need.
<?php
global $IN;
//Find out where the user came from
$fs_refer = $IN->GBL('HTTP_REFERER', 'SERVER');
$host_refer = parse_url($fs_refer);
$host_refer = $host_refer['host'];
//Extract the WebAlias variable for use with outbound links
$fs_refer = explode("=", $fs_refer);
//Grab First Name if it exists
$FirstName = $IN->GBL('FirstName', 'GET');
//Set the WebAlis for outbound links back to mydomain.com
if (($host_refer == "www.mydomain.com") OR ($host_refer == "mydomain.com")) {
$web_alias = $fs_refer[1];
} else {
$web_alias = "grace";
}
?>
A brief explanation of why I need these variables:
I am trying to capture a variable from the referring URL, which is generally in the following format. I will also need to be able to use this variable as a conditional variable within EE:
<a href="http://www.mydomain.com/page.aspx?ID=web_alias">http://www.mydomain.com/page.aspx?ID=web_alias</a>And here is the format (most of the time) that links are coming into the EE site from:
<a href="http://www.mydomain.com/page.aspx?ID=<?=$web_alias?>%22>Link">Link back to domain.com</a>In attempting to implement this as a template include which allows PHP, I get an error saying that the variables are undefined. I tried including them in the path.php global array, but as I understand it these cannot include and PHP or other code.
At this point, any advice on how to make this work would be greatly appreciated. Or, is there an entirely different and better way to do it, I’m all ears! I love EE thus far and am really looking forward to learning more and more as I go.
Cheers,
Michael R.