user2328338
user2328338

Reputation: 1

issues with Iframe and php include

I'm new to PHP and i use the include function to include a header file that has my db connections and my menu. On a body page I'm using a iframe to include a aside that needs to go on many different pages. The issue arises when i hit click on one of the hyperlinks of the aside that is in the IFRAME it will take me to the proper page BUT will RE-include the header in that portion of the code. I was wondering if there is any alternatives OR ways to insure the header doesn't reload in my iframe. Here is a copy of my code.

Main PAGE

<?php 
include_once("include/header.php");

?>
<div id="content">
 <div id="left" class="sidebar">
<iframe src="aside.php" height="550" frameborder="0" width="210" scrolling="no"      allowtransparency="true" rel="nofollow"></iframe>
 </div>

Aside page

<div class="imgholder">
      <p class="employeename">Pablo Israel Penaloza</p>
      <img src="img/Pablo-Peñaloza.jpg" width="202" height="150" class="imgemployee">
      <div class="sidebarmenu">
    <ul id="sidebarmenu1">
          <li><a href="personalinfo.php">Informacion Personal</a></li>
          <li><a href="#">Contacto</a></li>
          <li><a href="#">Contact de Emergencia</a></li>
          <li><a href="#">Dependientes</a></li>
          <li><a href="#">Imigracion</a></li>
          <li><a href="#">Deberes</a></li>
          <li><a href="#">Salario</a></li>
          <li><a href="#">Supervisor</a></li>
          <li><a href="#">Calificaciones</a></li>
          <li><a href="#">Membresias</a></li>
        </ul>
        </div>
    <!--End sidebarmenu1--> 
  </div>

Thank you

Upvotes: 0

Views: 3969

Answers (1)

AbsoluteƵER&#216;
AbsoluteƵER&#216;

Reputation: 7870

You'll need to use javascript for the detection, or make separate URLs for pages that will be included in the iframe. This should help you: Check if site is inside iframe

To not use an iframe would be best. It's much easier if you just use include(). You can make the content that would reside in the iframe inside of a scrolling DIV instead. Modern sites do this and update the <div> with AJAX.

To make it scroll

<div style='width:210px;height:550px;overflow:auto'>
   <?php include($_SERVER['DOCUMENT_ROOT'].'/includes/aside.php'); ?>
</div>

Static

<div style='width:210px;height:550px;'>
   <?php include($_SERVER['DOCUMENT_ROOT'].'/includes/aside.php'); ?>
</div>

Upvotes: 1

Related Questions