Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:40:39+00:00 2026-05-14T02:40:39+00:00

The problem is that when the content loads it displays before the tag before

  • 0

The problem is that when the content loads it displays before the tag before i added the <!DOCTYPE>, <html> <head></head> in the index.php file NOW $content loads before the Body tag… when it should beloaded in the “contents” div.

(1 I’m trying to get file_get_contents to load the links ?=about ?=services etc into to body.tpl in the contents div i have specified with #CONTENTS#

(2 The Dir Tree is as follows

 htdocs>
    classes> file.class.php
    contents> where i want #CONTENTS# (file_get_contents) to grab data from
    images> content (changing images)
    templates> where the templates are hosted
            clean>main template (Files are header.tpl, body.tpl, footer.tpl, styles.css, menu_style.css, and the images folder for images relating to the template itself.)
            other templates>(to come)

/* file.class.php */

<?php

$file = new file();

class file{
    var $path = "templates/clean";
    var $ext = "tpl";

    function loadfile($filename){
  return file_get_contents($this->path . "/" . $filename . "." . $this->ext);
 }

 function setcontent($content,$newcontent,$vartoreplace='#CONTENT#'){
  $val = str_replace($vartoreplace,$newcontent,$content);
  return $val;
 }

 function p($content) {
  $v = $content;
  $v = str_replace('#CONTENT#','',$v);
  print $v;
 }
}
if(!isset($_GET['page'])){
    ob_start();
    // if not, lets load our index page(you can change home.php to whatever you want:
    include("main.txt");
    // else $_GET['page'] was set so lets do stuff:
    } else {
    // lets first check if the file exists:
    if(file_exists($_GET['page'].'.txt')){
    // and lets include that then:
    include($_GET['page'].'.txt');
    $content = ob_get_contents();
    ob_end_clean();

    // sorry mate, could not find it:
    } else {
        echo 'Sorry, could not find <strong>' . $_GET['page'] .'.txt</strong>';
    }
}
?>

if some one could trim that down so it JUST is the template required code and file get contents.

/* index.php */

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="robots" content="index,follow"/>
<meta name="distribution" content="global"/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<link href="templates/clean/style.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" href="templates/clean/menu_style.css" type="text/css" />
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
</head>
<body> //everything before this USED to be in header.tpl but i moved it here until fix so that w3c validator would validate my code
<?php
    include('classes/file.class.php');

    // load the templates
    $header = $file->loadfile('header');
    $body = $file->loadfile('body');
    $footer = $file->loadfile('footer');

    // fill body.tpl #CONTENT# slot with $content
    $body = $file->setcontent($body, $content);

    // cleanup and output the full page
    $file->p($header . $body . $footer);

?>

/* header.tpl */

 <div id="header">
  <div id="logo"><a href="index.php" style="height:30px;width:150px;"><img src="images/logo.png" border="0" alt=""/></a></div>
   <div id="menuo"> 
    <div class="menu">
     <ul id="menu">
      <li><a href="?page=home">Home</a></li>
      <li><a href="?page=about">About Us</a></li>
      <li><a href="?page=services">Services</a>
       <ul>
        <li><a href="?page=instore">InStore Repairs</a></li>
        <li><a href="?page=inhome">InHome Repairs</a></li>
        <li><a href="?page=website">Website Design</a></li>
        <li><a href="?page=soon">Comming Soon.</a></li>
         </ul>
       </li>
      <li><a href="?page=products">Products</a>
                   <ul>
                   <li><a href="?page=pchard">Computer Hardware</a></li>
                   <li><a href="?page=monitor">Monitor's</a></li>
                   <li><a href="?page=laptop">Laptop + Netbooks</a></li>
                   <li><a href="?page=soon">Comming Soon.</a></li>
                   </ul>
             </li>
      <li><a href="?page=contact">Contact</a></li>
     </ul>
    </div>
   </div>
 </div>
 <div id="headerf">
 </div>

/* body.tpl */

   <div id="bodys">
    <div id="bodt"></div>
        <div id="bodm">
            <div id="contents">
                #CONTENT#
                </div>
    <div id="bodb"></div>
        </div>
</div>

/* footer.tpl */

<div id="footer">
<div style="position:absolute; top:4px; left:4px;"><img src="images/ff.png" alt="ok"></div> <div style="position:absolute; top:4px; right:5px; color:#FFFFFF;">&copy;2010 <a href="mailto:">Company Name</a></div>
</div>
</body>
</html>

My Firefox Showing The Problem In Action

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:40:39+00:00Added an answer on May 14, 2026 at 2:40 am

    Edited answer:
    I’d originally assumed that the p() method was an accidental method you were calling, but that appears (according to the update you made to fix the fact that both pages were the same) to be a red herring. The issue is similar maybe though.

    When you:
    include('classes/file.class.php'); as part of your index.php, one of the things it does is define the methods and then run a few if statements, as part of this change it includes a .txt file. (e.g. include("main.txt");).

    My guess is what you are seeing is the contents of this include file being displayed to screen. What’s the point of them being included? Can you just remove them? Should you really just be reading the content to a variable instead of including it (and effectively echo’ing/printing it to screen)?

    Try removing them and seeing if that solves your issue – but otherwise, check to make sure your template files contain what you think they contain. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.