You are here:  » Inserting PHP code into a template

Support Forum



Inserting PHP code into a template

Submitted by dazfree on Mon, 2008-11-24 11:29 in

Hi,

I made a simple template that I want to integrate Price Tapestry PHP code into.

However when I enter the code into my homepage it messes up the styles of the homepage. For example my template has margins for the body tag but when I then include the php code from the index.php file it totally messes up the margins.

What do I need to change/edit so that the php code for the index/product pages does not mess up my current templates? I've looked at the default.css file however I am not too sure on what to change.

Thanks,

Darrell

Submitted by support on Mon, 2008-11-24 12:10

Hello Darrell,

It's probably a case of the CSS being included by html/header.php and the BODY tags overriding your existing template.

The best thing to do in order to make the Price Tapestry output appear within your own design is to create a blank page containing nothing but your header and footer; and then split that up taking all the HTML above where you want the Price Tapestry content to appear and pasting that into a new version of html/header.php, and the reminder (i.e. everything below where you want the content) into html/footer.php.

Having done that, your template should be applied to every page; so if you are using search engine friendly URLs, make sure that the paths to your resources (css, images etc.) are fully qualified (i.e. beginning with "/") so that they can be found from any page on your site.

Finally, there is a little PHP involved in the existing html/header.php that generates the dynamic title and meta tags for SEO purposes:

<title><?php print (isset($header["title"])?$header["title"]:$config_title); ?></title>
<?php if (isset($header["meta"])): foreach($header["meta"] as $name => $content): ?>
<meta name='<?php print $name?>' content='<?php print $content?>' />
<?php endforeach; endif; ?>

...you should be able to insert the above code into your new html/header.php in place of any <title> tag that you may already have.

Hope this helps!

Cheers,
David.