Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cells or Frames ? 1

Status
Not open for further replies.

maverick

MIS
Apr 21, 1999
193
0
0
US
Hey guys,
I've been asking many people, mostly friends...
and everyone tells me not to use frames if at all possible
but,
It's so much easier to use frames then cells...
for instance if I want to load a page with an include statement, but I want the page to load in a cell in a table,

how do I do this ?

it seems to be a real pain, frames are so easy to deal with...

thanks guys

;-)

--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
Is there a PHP question here?

Basically, if you have the ability to use server side includes or a server side scripting language (which I expect you do, since you post in the PHP forum), you can accomplish all that frames offer without using them. The only advantage to frames is not having to repeat the same code on every page and by including files at server, you can do just that.

When you include a page, once the page is server to the viewer it will be merged with your base document and everything from the included document. To answer your question, output html to create a table in your base document, include your stuff (just what you want, no <html> and <body> tags), and close your table. For example:
Code:
--- Base.php ---

<?php
echo '<html><head><title>Page</title></head>';
echo '<body><table><tr><td>';
include 'stuff.txt';
echo '</td></tr></table></html>';
?>

--- Stuff.txt ---

<p>This is inside the cell</p>
This is a very basic example but should give you enough to understand the technique. As you can see, one advantage over frames is already visible - lower server load since included files contain only neccessary code as opposed to frames, where they have to be completely separate html pages.
 
Thanks,
that was very informative, but
I guess I didn't explain well enough...

I need to be able to click a link in my menu that is in one cell and have the linked page open/load in another cell of the same table,

which is what I can do with frames pretty easily

hope this is a better definition of question...

thanks !

--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
You cannot do that but you can fake the effect of doing that. In users eyes, there is no difference if the whole page refreshes (since it is loaded from cache it happens instantly) or only one frame. Say you have three links: home, about and contact. You could do this:
Code:
-- Menu.html --

<a href="?page=home">Home</a><br />
<a href="?page=about">About</a><br />
<a href="?page=contact">Contact</a><br />

-- Main.php --

<?php
 echo '
  <html>
   <head>
    <title>' . $_GET['page'] . '</title>
   </head>
   <body>
    <table>
     <tr>
      <td>';
 include 'Menu.html';
 echo '
      </td>
      <td>';
 $content = $_GET['page'] . ".txt";
 include $content;
 echo '
      </td>
     </tr>
    </table>
   </body>
  </html>';
?>
From here on you just need to create a few .txt files with the contents (and name them as used by the menu) and that is it. You are simulating all the positive sides of frames but avoiding the negative ones.
 
WOW !

That really works well !

I'm very impressed, I have been looking for a simple solution to this issue, and you should see some of the complicated methods people have come up with...

I will test this further, but so far so good !

Thanks
Star4U



--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top