You are here:  » Include_once


Include_once

Submitted by wesse249 on Wed, 2016-01-06 21:57 in

Hello David,

I wan't to include another website of myself into the front page of {link saved}

But i have some problems with it. For example i have now included example.com

No image and style sheets are loaded.

Do you no how ican solve this? And how can i made the webpage wider like my productpage for example: {link saved}

I use these code:

<div class='pt_sf'>
<div class='row'>
<div class='medium-6 medium-centered columns'>
<form name='search' action='<?php print $config_baseHREF ?>search.php'>
<div class="row collapse">
<div class="small-10 columns">
<input required="required" type="text" name="q" value="<?php print (isset($q)?str_replace(array("merchant:","category:","brand:",":"),"",$q):""); ?>">
</div>
<div class="small-2 columns">
<button class="button tiny postfix"><?php print translate("Search"); ?></button>
</div>
</div>
</form>
<?php if (strpos($_SERVER["PHP_SELF"],"index.php")!==FALSE): ?>
<img src="images/home.png" />
<?php include_once("http://www.example.com/");  ?>
<?php endif; ?>
</div>
</div>
</div>

Submitted by support on Fri, 2016-01-08 09:27

Hello Jan,

It wouldn't really be appropriate to incline include the entire content of an external web page into the body of another page since you would have duplicate html, head and body tags and would certainly invalidate the markup of the page.

What would be best, would be to add support for a flag to your external page that you wish to include, and if the flag is set suppress the HTML header and body tags and just output the body HTML. Make sure that the src attribute of any script or img tags are fully qualified - if they are relative URLs (e.g. beginning with just "/") the browser would be looking for the files on the website that the page was being included on. Consider the following:

<?php if (!isset($_GET["inline"])): ?>
<html>
  <head>
    <title>Example</title>
  </head>
  <body>
  <?php endif; ?>
    <style type='text/css' src='http://www.example.com/styles.css' />
    <h1>Example</h1>
    <img src='http://www.example.com/picture.jpg' />
  <?php if (!isset($_GET["inline"])): ?>
  </body>
</html>
<?php endif; ?>

The above would work directly as a full web page:

http://www.example.com/

...or inline as per the method in your code:

http://www.example.com/?inline=1

See how the inline $_GET parameter being set supresses the html, body and head markup from the output using the inline IF constructs.

To increase the width of your pages (allowing the .row class to extend to 100% rather than fixed width centered) add the following to the end of html/default.css:

  .row {
    max-width: 100% !important;
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com