We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Include template from outside of EE

Development and Programming

Swedie's avatar
Swedie
61 posts
14 years ago
Swedie's avatar Swedie

I’m converting an old system of mine that has crappy old PHP code. It uses a header and a footer by simply every index page runs a require(“header.php”) at the top and footer in the bottom.

Now, I’ve created the new site’s header and footer in the EE template system. I can reach these by typing /layout/header for example. I then see a correct header and footer.

But it of course doesn’t work using require as it requires a physical file on the server.

Is there anyway I can run the EE header and footer, with PHP code, on my old php pages that I have yet to convert but still need to be online and working?

I can use file_get_content to read the EE header and footer, but the session of the user won’t be recognized and all users will appear logged out.

I hope I make myself understood here. If not, let me know and I’ll try to explain differently. Thanks

       
Swedie's avatar
Swedie
61 posts
14 years ago
Swedie's avatar Swedie

Well, I apparently figured it out myself rather quickly.

Here’s the hack, and it works great! 😊

<?php
$_SERVER['PATH_INFO'] = "/layout/header";
include("index.php");
?>
       
Swedie's avatar
Swedie
61 posts
14 years ago
Swedie's avatar Swedie

Although seeing the header load apparently causes EE to make havoc with all my old classes etc. Not good.

I guess this means it’s a no go and I have to rewrite all the code. No likey.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.