You are here:  » Integrate with IPS Header and Footer


Integrate with IPS Header and Footer

Submitted by ajmboy on Mon, 2017-01-30 13:29 in

Hello, has anyone by change integrated price tapestry with IPS in terms of using their skin wrapper around price tapestry?

Looking for something to work like this post in their support forum: {link saved}

Submitted by support on Mon, 2017-01-30 15:48

Hi,

I wasn't able to access the forum post you mentioned, but have a look at the new Classic template. This is designed to work enclosed within any 3rd party template or existing website. I'm going to prepare a more comprehensive guide to this process, but essentially it would involve replacing html/header.php with whatever code is required to wrap _above_ Price Tapestry content, and html/footer.php with whatever code is required to wrap _below_ Price Tapestry content.

Then at the _end_ of the new html/header.php, add the following:

<link rel='stylesheet' href='<?php print $config_baseHREF?>html/layout.css' />
<link rel='stylesheet' href='<?php print $config_baseHREF?>html/style.css' />
<div class='pt'>

And finally at the _top_ of the new html/footer.php, add the following:

</div>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Tue, 2017-01-31 00:41

David, thank you so much for getting back to me so fast. I didn't realize that the post was blocked off to guests on that site. Basically, in that forum software suite, there is the ability to create a page with just the footer and header (wrapper) and then place content inside. I don't want to run price tapestry in an iframe or anything like that. One of the support staff mentioned:

You could create a new page with the wrapper like so (simplified of course here).

<html>
  <head>
    ...
  </head>
  <body>
    ....
    <!--CONTENT-->
    ...
  </body>
</html>

Say you had that at site.com/template.html

You could load that with something like:

$myContent= "My Stuff here";
$template = file_get_contents("http://example.com/template.html");
$template = str_replace( '<!--CONTENT-->', $myContent, $template );
header("Content-type: text/html");
print $template;
exit();

The would need to be pricetapestry I guess. I'm not sure if it's possible to reverse pull that wrapper content like that.

Submitted by support on Tue, 2017-01-31 09:08

Hi,

I'm assuming that template.html contains the full header and footer HTML required - in which case, you could try as a simple test in the first instance;

1) Make a sub-directory with an appropriate name for the price comparison part of your site e.g. /comparison/ or /shopping/

2) Inside that folder, make a test file comparison/test.php as follows;

<?php
  $myContent
"<h1>Shopping</h1>";
  
$template file_get_contents("../template.html");
  
$template str_replace'<!--CONTENT-->'$myContent$template );
  
header("Content-type: text/html");
  print 
$template;
  exit();
?>

Then browse to http://example.com/shopping/test.php and if you see the H1 title "Shopping" nicely contained within your top level site's header / footer then it should be straight forward from there as PHP's output buffering functions can be used to capture the full Price Tapestry generated page body and effectively just do the above in Price Tapestry's html/footer.php file - as well as swap out the title (easily done with a preg_replace on the template) and insert the meta tags into the head...

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Tue, 2017-01-31 13:11

That works, I just tested and am getting the H1 output within teh header/footer of my CMS. So the $myContent would be basically price tapestry, correct? Could you explain what I would put in html/footer.php ?

Thanks for your help David!

Submitted by support on Tue, 2017-01-31 14:59

Great!

OK, bear with me and I will set-up a simulation of the same directory structure and top level template file on my test server. In the mean time, if you could proceed with the installation of Price Tapestry in the /comparison/ sub-directory (or whatever name you have used), bearing in mind that when installing into a sub-directory; in config.php use at line 6:

  $config_baseHREF = "/comparison/";

And in .htaccess (made from htaccess.txt in the distribution), and assuming you want to enable search engine friendly URLs with $config_useRewrite set to TRUE in config.php, use at line 5:

RewriteBase /comparison/

After installation, install the Classic template ready for inclusion within your top level template.html wrapper.

Let me know once that is all set-up, and confirm the actual sub-directory name that you used for the Price Tapestry installation (e.g. /comparison/) and I'll follow up with the header / footer mods for incorporation into your top level template file as soon as I've run it through on my test server...

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Tue, 2017-01-31 17:34

All set up and installed classic theme. PT is in {link saved}

Submitted by support on Wed, 2017-02-01 13:38

Hi,

Firstly, make sure that your top level template.html file _does not_ include a <title>...</title> element as this will be added by the replacement template files below.

With that in place, upload to your Price Tapestry installation replacement files as follows:

html/header.php

<?php
  ob_start
();
  print 
"<div class='pt'>";
?>

html/footer.php

<?php
  
print "</div>";
  
$footer_content ob_get_contents();
  
ob_end_clean();
  
$footer_template file_get_contents("../template.html");
  
$footer_template str_replace("<!--CONTENT-->",$footer_content,$footer_template);
  if (!isset(
$header["title"]))
  {
    
$header["title"] = $config_title;
  }
  
$footer_header "";
  
$footer_header .= "<title>".htmlspecialchars($header["title"],ENT_QUOTES,$config_charset)."</title>";
  foreach(
$header["meta"] as $name => $content)
  {
    
$footer_header .= "<meta name='".$name."' content='".htmlspecialchars($content,ENT_QUOTES,$config_charset)."' />";
  }
  
$footer_header .= "<link rel='stylesheet' href='".$config_baseHREF."html/layout.css' />";
  
$footer_header .= "<link rel='stylesheet' href='".$config_baseHREF."html/style.css' />";
  
$footer_header .= "<script src='".$config_baseHREF."html/vendor/jquery.min.js'></script>";
  
$footer_template str_replace("</head>",$footer_header."</head>",$footer_template);
  
header("Content-type: text/html");
  print 
$footer_template;
  exit();
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Wed, 2017-02-01 23:54

David, thank you, it works perfectly. I had to use the actual template url in $footer_template = file_get_contents("../template.html"); because it's not actually a file but dynamically created at the url by the cms. So I just changed it to https://www.example.com/template.html

I'm just wondering if its not good to have the http call on every page load, but I don't think its a big deal. Main thing is its wrapped!

Much appreciated, I'm going to start modifying the css and see about some of the api modules.

Submitted by support on Thu, 2017-02-02 08:59

As the request to the http served template will be coming from the same server there should not be any external network involvement so not a big deal at all!

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Sun, 2017-03-12 02:16

Hi David, if all of a sudden I am getting no output in the body or in this test script, do you know what might be disabled in php or apache now to not allow this? Something changed on my end and I'm trying to figure it out.

allow_url_fopen = On
allow_url_include = On

I can load that test.php and am getting header and footer just not getting $myContent= "Shopping";

Like str_replace isn't working.

Submitted by support on Mon, 2017-03-13 09:57

Hi,

The relevant setting would be;

  allow_url_include = On

...however, from your description (the fact that you are seeing header and footer) it looks like to be one of two things, firstly that something has happened to the template and it no longer contains:

<!--CONTENT-->

One way to check this, and would at the same time confirm whether the problem is due to the capturing of the output in order to make the str_replace, would be to edit html/footer.php and comment out the following line:

  $footer_template = str_replace("<!--CONTENT-->",$footer_content,$footer_template);

With the above commented out, view your page and then use your browser's View > Page Source function to view the HTML and then look for the <!--CONTENT-->.

- If you cannot see <!--CONTENT--> in the output, double check the template itself and that should be all it is (don't forget to uncomment the above line of course)

- If you can see <!--CONTENT--> next uncomment the above code and repeat the test. Now when viewing the source, if you cannot see <!--CONTENT--> that would mean that something has happened to the output buffering / capture - in other words this code;

  $footer_content = ob_get_contents();
  ob_end_clean();

...in which case let me know and I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Tue, 2017-03-21 01:35

Finally got this working. For some reason my CMS is not processing the comment tag anymore as an output in the source code after their latest update.

To test, I replaced with %parts% and it started working. However, now my title tags and meta info is not being replaced. Still looking into why that is.

Submitted by support on Tue, 2017-03-21 08:39

Hi,

I assume you made the following replacement in the code from above in html/footer.php

  $footer_template = str_replace("%parts%",$footer_content,$footer_template);

So if that'a all good now, for the title / meta tags not be inserted look towards this line;

  $footer_template = str_replace("</head>",$footer_header."</head>",$footer_template);

...so it's relying on </head> being present in the template, which if it intended to be a standalone web page should be the case but that would be the first thing to check. Let me know if you'd like me to take a look at the site if you're still not sure (I'll remove any URLs before posting your reply)...

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Tue, 2017-03-21 12:18

Thank you so much, I appreciate it. I see </head> in the source.

PT is at {link saved}

Submitted by support on Tue, 2017-03-21 13:07

Hi,

It looks like the Price Tapestry generated title and meta tags are being inserted fine, but the template itself contains a <title> and since it appears first that is what is displayed by the browser, but it can be removed easily.

In html/footer.php where you currently have this code:

  $footer_template = str_replace("</head>",$footer_header."</head>",$footer_template);

...REPLACE with:

  $footer_template = preg_replace("/<title>(.*)<\/title>/","",$footer_template);
  $footer_template = str_replace("</head>",$footer_header."</head>",$footer_template);

...and that should do the trick!

Cheers,
David.
--
PriceTapestry.com

Submitted by ajmboy on Tue, 2017-03-21 13:42

David, that worked perfectly! Thank you so much for the fast response and support outside the scope of normal support :) I really appreciate it!