You are here:  » Including Includes within IFRAMEs?


Including Includes within IFRAMEs?

Submitted by madstock on Thu, 2006-09-14 10:28 in

Sorry, not the best title, although you will be pleased to hear that I will bother you no more (possibly) after this...

Basically on our soon-to-be-new site every merchant has a 3 digit id, which is set as their "brand" - this is constant througout several databases.

As such to a version of PT with their database can be found at:

http://www.site.com/MERCHANTIDNUMBER/

Also, powered by a seperate database (that has all of the merchants, with descriptions, direct-link url and category), we have a page that is of the format:

http://www.site.com/details.php?q=brand:MERCHANTIDNUMBER

I would like to be able to stick the latter within the former as an iframe (an include would be far, far better, however there would possibly be a massive amount of conflicting variables) so that for example within

http://www.site.com/001/

there is the line

print "<center><****** src='http://www.site.com/details.php?q=brand:001' width='90%' height='160' scrolling='no' frameborder='0'></******></center>";

(where ****** is IFRAME - cannot be posted on this forum)

I would think this would invove creating another variable by taking the " .$config_baseHREF ." and running a str_replace, changing:

http://www.site.com/001

to

http://www.site.com/details.php?q=brand:001

and the sticking the resulting URL within the IFRAME (or even better include).

In theory this sounds really simple, but having tried about 36 different ways of phrasing it I am just becoming more and more confused.

Would some kind soul please put me out of my misery!

Thanks,
Duncan

Submitted by support on Thu, 2006-09-14 11:05

Hi Duncan,

I'm afraid I don't quite follow the problem you're having. Is that the links within the IFRAME included site open within the frame, and you want them to open in main browser window?

What happens at the moment? You have the IFRAME in place so presumably you are seeing the page contents displayed properly...?

Cheers,
David.

Submitted by madstock on Thu, 2006-09-14 11:16

Sorry, I should have explained better.

I don't have the IFRAMEs in place as of yet, as I cannot get the URL right (it is to be dynamic).

Basically I need to form the IFRAME (or include) URL in the following style:

http://www.site.com/details.php?q=brand:SITEID

This is to be inserted on the page with the base HREF of:

http://www.site.com/SITEID

So my thought was to create a seperate string, which was made by using str_replace on the $config_baseHREF field, and stick this in as the URL.

Sorry for rambling!

Submitted by support on Thu, 2006-09-14 11:56

That would certainly work. You can extract $q from the query as usual, and use the same explode() code as in search.php. That will put SITEID in $parts[1], which you can use to construct $config_baseHREF:

<?php
  $q 
$_GET["q"];
  
$parts explode(":",$q);
  
$config_baseHREF "http://www.site.com/".$parts[1];
?>

...although it may need a forward slash at the end:

  $config_baseHREF = "http://www.site.com/".$parts[1]."/";

Hope this helps!
David.

Submitted by madstock on Thu, 2006-09-14 12:50

Thanks again - I have now sorted it using the following botched-together code, which does exactly what I want (with the exception of the output being an IFRAME instead of an include):

<?php
$basecode_url 
str_replace("/"""$config_baseHREF);
$basecode2_url str_replace("http:site.com"""$basecode_url);
print 
"<center><i*rame src='http://www.site.com/details.php?q=brand:$basecode2_url' width='90%' height='140' scrolling='no' frameborder='0'></i*rame></center>";
?>

Hopefully I will have a site to show for this in the next few days!

Thanks, as always, for your help - sorry if I didn't explain myself, yet again.