Re: (more html related) Access and modify different frames



On Jan 5, 6:08 am, InuY4sha <inuy4...@xxxxxxxxx> wrote:
Hi all,
I'm a very inexpert dude who's writing his own website.
I've got the following stuff to deal with:
3 frames divided as follow
-----------------
|menu.php |
-----------------
|focus.php |
----------------
|body.php  |
----------------
focus.php is basically a html table of images matching the menu items.
Eeach image gets emphasized when the corresponding menu item is
clicked.

My issue is the following: without the help of js, I'd like to click
on an item of menu.php, and through clicking it, refreshing body.php
and focus.php accordingly to the choice performed.
In order to do so, I'm currently using 2 instead of 3 frames: the
first is menu, while the latter embeds both focus.php and body.php
subframes:
------------------------
|    menu.php     |
|-----------------------|
|     body.htm    |
|    _________   |
|    |focus.php |  |
|    ----------------   |
|    |body.php  |  |
|    ----------------  |
------------------------
Embedding focus and body lets me do what I need but is imho very
dirty; I mean, it makes me write "body.htm" only to embeds the real
file body.php... (which is most of the times a mere html file).
Isn't there a cleaner way to do this all, instead of basically have 2
files for each single content?

I was thinking of having a focus.php refresh itself upon a certain
event such as body changing... is something like this possible through
php?

Note that I need focus to be separated from body subframe as I don't
want it to be scrollable -only body has to- !

How to ?

First off, using a frames approach is both inelegant and outdated.
However, it is also an excellent place to start for a beginner. In
the future you're going to want to use AJAX and the DOM to manipulate
page content and javascript to modify existing elements' appearances.

Secondly, Jerry is wrong when he says "PHP knows nothing about what
goes on on the client". State can be communicated across pages in
many ways: querystrings, cookies, hidden form values, and session
variables are the ones that come immediately to mind.

Ok then! Having said all that, my recommendation is that you use NO
frames here. Combine menu+focus into a framing page, and insert your
content by using separate PHP files that you include as necessary.
(eg) frame.php:
....
<body>
<div id=menu>
<a href='/pages/frame.php?f=1'>Menu Item 1</a>
<a href='/pages/frame.php?f=2'>Menu Item 2</a>
...
...
<a href='/pages/frame.php?f=n'>Menu Item n</a>
</div>
<div id='content' style="height:400px; overflow:scroll">
<?php require_once("body.php"); ?>
</div>
<table id='focus'></table>
</body>
....


So how to get different content & emphasized images when a menu item
is clicked? Easy. Use the switch passed in from the menu item's
URL's querystring, which indicates the desired content. (eg)
frame.php:
....
<a href='/pages/frame.php?f=1'>Menu Item 1</a>
....

So how to use this? Well, for the content we'd modify frame.php a bit
to use conditional includes. (eg) frame.php:
....
<?php
$flag =@$_GET["f"];
?>
....
<body>
<div id=menu>
<a href='/pages/frame.php?f=1'>Menu Item 1</a>
<a href='/pages/frame.php?f=2'>Menu Item 2</a>
...
...
<a href='/pages/frame.php?f=n'>Menu Item n</a>
</div>
<div style="height:400px; overflow:scroll">
<?php
switch($flag) {
case 1:
require_once("/content/body1.php");
break;
case 2:
require_once("/content/body2.php");
break;
...
...
...
default:
echo("Please click a menu item.");
break;
}
?>
</div>
<table id='focus'></table>
</body>
....


Well and good! But what about image emphasis? Same trick, but use an
if statement instead of a switch. (eg) frame.php:
....
<table id='focus'>
<tr>
<td>
<?php
if($flag == 1) { echo("<img src='/images/1.emphasized.gif' />")' }
else { echo("<img src='/images/1.gif' />")' }
?>
</td>
...
...
<td>
<?php
if($flag == n) { echo("<img src='/images/n.eEmphasized.gif' /
")' }
else { echo("<img src='/images/n.gif' />")' }
?>
</td>
</tr>
</table>
....

There you go - a menu driven system in php, just one page, and no
javascript. The code isn't elegant, but since it's written for
clarity that's to be expected. Is that what you were looking for?

Tyler Style
http://malthusian-solutions.com
http://nirdvana.com
.



Relevant Pages

  • Re: Inline frames, die, die, die (aka please help!)
    ... IFrames have all of the same annoying problems as do frames. ... > .php page as well. ... > Another solution is just have these pages open in new browser window. ... > will go directly to the IFrame content, ...
    (microsoft.public.frontpage.client)
  • RE: [PHP] one click - two actions?
    ... Technically when php prepares the page, ... you used frames you could cause the left frame to be a separate PHP ... I have a single page and both results load in the same page. ... The first php page needs to contain javascript to open a ...
    (php.general)
  • Re: [PHP] Audio CAPTCHA review request
    ... that's more expensive than a bots and I like making spammy's job harder and more expensive. ... So just creating an AVI made up from a few simple frames. ... with different frame rates) and then creating an movie from ... Php animation could be done via ajax. ...
    (php.general)
  • Re: [OT] (more html related) Access and modify different frames
    ... focus.php is basically a html table of images matching the menu items. ... I'm currently using 2 instead of 3 frames: ... There isn't anything you can do in PHP. ... All PHP dies is respond to requests; those requests may be a frame or an entire windows; that's determined by the browser and HTML code, ...
    (comp.lang.php)
  • RE: [PHP] PHP with Frames (cont.)
    ... Are you trying to access variables between frames or just get a php script ... You could not access variables between the frames though. ...
    (php.general)