Page 1 of 1

Get $Url of Site Hosting Iframe?

Posted: Wed May 19, 2010 4:51 pm
by mbarrio
Okay so here is what I'm looking to do, pretty new to php as you will tell by my code :P. The code I have works great for Site1 and Site3 but is what I'm trying to accomplish is:
Site1 is hosting the site which dynamicly shows content according to Url name. Does this great. But now I would like Site2 to be just an Iframe of Site1 and have it display dynamic content for Site2 not Site1

Here is the code I have... I hope this makes sense

Code: Select all

function getDomain($url)
{
    if(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) === FALSE)
    {
        return false;
    }
    /*** get the url parts ***/
    $parts = parse_url($url);
    /*** return the host domain ***/
    return $parts['scheme'].'://'.$parts['host'];
}

Code: Select all

<?php
$domain = getDomain($url);
if ($domain = 'http://Site1') {$service='xxxxxx';} // show the phone numbers
if ($domain = 'http://Site2') {$service='xxxxxx';} // show the phone numbers
if ($domain = 'http://Site3') {$service='xxxxxx';} // show the phone numbers
echo '<p style="margin:0px 0px 10px 0px; font-size: 20px; font-weight:bold;"><img src="call-us.gif" alt="'.$service.' Questions" title="'.$service.' Questions" width="24" height="24" class="alignnone size-full wp-image-219" />&nbsp;&nbsp;'.$service.'</p>
<p style="margin:0px; font-size: 20px; font-weight:bold;"><img src="call-us.gif" alt="'.$service.' Questions" title="'.$service.' Questions" width="24" height="24" class="alignnone size-full wp-image-219" />&nbsp;&nbsp;'.$service.'</p>';
?>

Re: Get $Url of Site Hosting Iframe?

Posted: Wed May 19, 2010 6:47 pm
by AbraCadaver
Put something in the URL of the iframe src, like:

Code: Select all

<iframe src="http://site1.com?site=site2">
Then in site1 code, something like:

Code: Select all

if(isset($_GET['site'])) {
   $domain = $_GET['site'];
}

Re: Get $Url of Site Hosting Iframe?

Posted: Thu May 20, 2010 8:40 am
by mbarrio
Great I will plug that in a test it! Thank you!