Thomas K Posted September 30, 2013 Share Posted September 30, 2013 Does anyone know if there's a trick to include a PW header & footer into another PHP script? I would like to have the same header and footer on an old ordering system as I have on the main website programmed in PW. I've tried to make a header page, that simply shows the header of the website, but I cannot include('path/to/headerpage') in my other PHP script?? This works: // Include ProcessWire require("../index.php"); // Get header $header_page = wire()->pages->get("/external_head/"); echo $header_page->url; This does not work for me: // Include ProcessWire require("../index.php"); // Get header $header_page = wire()->pages->get("/external_head/"); include($header_page->url); Link to comment Share on other sites More sharing options...
Pete Posted September 30, 2013 Share Posted September 30, 2013 I'm confused - this would surely just echo the URL of that page: echo $header_page->url; ?? To render it you would want this instead: $header_page->render(); So in your other script, you could do this: // Include ProcessWire require("../index.php"); // Get header $header_page = wire()->pages->get("/external_head/"); $footer_page = wire()->pages->get("/external_foot/"); echo $header_page->render(); //.... the rest of your other script goes here echo $footer_page->render(); That should work I think, unless I've misunderstood what you're asking for. It also assumes that there will be no conflicts between variables in ProcessWire and your other script, but you would know if that's the case soon enough when it throws you errors I must admit, I do like the concept. I know of an intranet script I've worked on in the past where I tried to make ProcessWire work inside that script's header and footer for old pages, and new pages had the header and footer and the pages themselves in ProcessWire, but this would have been a better idea in terms of wrapping a consistent header and footer around both the old and the new pages until they're all ported over to ProcessWire. 2 Link to comment Share on other sites More sharing options...
Thomas K Posted September 30, 2013 Author Share Posted September 30, 2013 It works! Thx a lot Pete. It's my first project with PW, so I did not know the $page->render() function...so simple PS. Sorry for the confusion with echo $header_page->url; I was just trying to show that I had access to the pw api from the other script. Link to comment Share on other sites More sharing options...
Pete Posted September 30, 2013 Share Posted September 30, 2013 No worries, if you run into anything else then let us know. A really useful tool for the most common functions is the cheatsheet if you've not already seen it: http://cheatsheet.processwire.com/ Welcome to ProcessWire by the way, and have fun! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now