Jump to content

Passing HTML into Template Page


millsy007

Recommended Posts

I have set up two pages, content.php and template.php, I was the content.php file to contain a variable that will contain all the html for my content that will then be displayed within my template.php file, mostly this works fine. However the problem I have is that I want additional html in my content.php file so that when other people are editing it looks more like the finished file. My problem is that when I add this additional html it is being passed into the template.php file even though it is not within the content variable. Hopefully this code snippet will explain it:

 

template.php

 

<html><head><head><body
<table width="100%" cellpadding="10" cellspacing="0"><tr><td width="30%" valign="top" bgcolor="#EEEEEE">
Beach Hostel is located right next to one of Holland’s beautiful beaches.   There’s nothing that can beat the sound of waves and the tranquility of the   beach-life, especially after you’ve been surrounded by the madness of the city   (of Amsterdam) for a while. This Flying Pig Hostel is known for offering you the   best chill out spot you can imagine; in this backpacker hostel you can relax,   smoke, hang out with friends, party or challenge your limits and abilities in   various beach sports!
</td>
<td width="70%" valign="top">
<?php echo $content; ?>
</td></tr></table>
</body></html>

 

content.php

 

<p>TEST CONTENT - this is displayed even though it is outside the php tags?</p>

<?php ob_start(); ?>
    
<p>The Beach Hostel is located right next to one of Holland’s beautiful beaches. There’s nothing that can beat the sound of waves and the tranquility of the beach-life, especially after you’ve been surrounded by the madness of the city (of Amsterdam) for a while. This Flying Pig Hostel is known for offering you the best chill out spot you can imagine; in this backpacker hostel you can relax, smoke, hang out with friends, party or challenge your limits and abilities in various beach sports!</p>
<?php 
//Assign all Page Specific variables  
$content = ob_get_contents();  
ob_end_clean();   
//Apply the template  
include("template.php");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.