Forum Moderators: coopster

Message Too Old, No Replies

trying to create a template class

template, php objects, classes

         

willis1480

4:19 pm on Nov 17, 2008 (gmt 0)

10+ Year Member



Well, although I am not a "novice" php developer, I have done little object programming.

I am getting tired of integrating opensource projects into existing CMS and custom websites.

Is there a way to load then entire page created by phpBB, osCommerce, or whatever into a string.

I could then parse the entire HTML string to add correct head elements to my template head, body, footer, etc...

example:
class HTMLwrapper{
var $loadFile;

function loadHTML($loadFile){
//get the contents of the opensource file being requested and return in a string
}
fuction getHead(){
//return the head of the loaded opensource file
}
function getStyles(){
//return the style sheets of the loaded opensouce file
}
etc....
}

Get the idea? Then I can use URL rewriting to always point files to my template page and load the data to the body of my pages. I know this will not resolve left hand navigation and such for each opensource. But a start is all I am looking for right now.

Thanks in advance.

PS. the issue I am having is really with phpBB3. cant figure out how it is displaying the pages content and keeping all the vars correctly. not sure how it is displaying things...ill keep searching though.

coopster

11:56 pm on Nov 18, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not quite certain I understand where you are headed with this yet, but ...

Is there a way to load then entire page created by phpBB, osCommerce, or whatever into a string.

Yes. There are a few different ways you can perform such tasks. One is to start output buffering and flush the buffer after getting it's contents into a string variable. Another is to read the file from a URL into a string using a function such as file_get_contents [php.net]. Note that if the URL is on the same server you may have issues if you have a firewall in place. Many firewalls will not route the request back to the server so you might end up adding an entry to your /etc/hosts file.

willis1480

12:53 am on Nov 19, 2008 (gmt 0)

10+ Year Member



file_get_contents() works like fread()...i am not looking to read the file as a string without the php being evaluated. eval() doesnt really work well for entire files.

1) I want to get the HTML that is sent to the browser in a string( with all PHP evaluated).
2) Evaluate it.
3) Then send it to the browser.

willis1480

2:11 am on Nov 19, 2008 (gmt 0)

10+ Year Member



ahhhh...i didnt realize i had to do it via a URL. I was accessing it directly.

example:
$filename = "myfile.php";
vs.
$filename = "http://mydomain.com/myfile.php";

Thanks