Forum Moderators: coopster
1.php - Needs the HTML title initially but should not include other HTML content from 2.php until later in the body.
2.php - Has the title and the content though needs to serve both to 1.php separately.
Someone suggested Model View Controller though I'm not finding anything on php.net. I'm not exactly sure what I'm looking for.
I want the file 2.php to merely have a title in some sort of variable that I can insert in to the title element which is physically present in file 1.php.
Then I want to have my normal content below the title variable.
The issue is I only want to call the title from file 2.php and not have the body element's content. I don't need to get any more sophisticated then that. I know how to work with PHP classes (I think the original thread is at [webmasterworld.com...]
Oh and no I don't want to use some prebuilt script to achieve this. The complexity of my goal doesn't seem that complex. :)
- John
$content is assigned via the heredoc [us3.php.net] syntax. In 1.php you just include '2.php' and then echo $title and $content in the appropriate spots.
If you need 2.php to be standalone as well as capable of being subcontent for 1.php, 2.php could look something like this:
<!doctype html ....>
<!--BREAK--><!--page2--><!--BREAK-->
<html>
<body>
<!--BREAK--><p>Now is the time for all good men</p>
<p>And then the duck said</p><!--BREAK-->
</body>
</html>
In 1.php use file_get_contents or fread or whatever to get the file into, say, $doc. Then,
$parts = explode("<!--BREAK-->",$doc);
$title = substr($parts[1],4,-3);
$content = $parts[3];