472,133 Members | 1,519 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

alternative to frames in php?

everywhere I go, i get told "don't use frames, use php instead"

ok... so how do i go about it?

I want a top banner that doesn't move, and a "contents" type list on the
left (that may have a scroll bar)
and the rest of the window is the main page (obviously)

now, I dont want all 3 areas to be loaded/repainted when i click a link on
the contents, just the "main area"

Is this achievable in php?

Thanks in adavance
Jul 17 '05 #1
12 6420
David <lo********@yahoo.co.uk> wrote:
everywhere I go, i get told "don't use frames, use php instead"

ok... so how do i go about it?
Why not ask the people that tell you to use php instead of frames? They
surely have done that themselves!
I want a top banner that doesn't move, and a "contents" type list on the
left (that may have a scroll bar)
and the rest of the window is the main page (obviously)

now, I dont want all 3 areas to be loaded/repainted when i click a link on
the contents, just the "main area"

Is this achievable in php?


Not without using (i)frames.

Use frames, what you want is what they can be used for. You just have to
remember the limitations imposed by frames. Ask the people who say that
you shouldn't use frames to explain these to you.

Jul 17 '05 #2
"don't use frames, use php instead" ?

That's like saying, don't drive, use gasoline instead.
What you're asking to do can't be done in php (repainting a single
section) since that isn't what php does. Look into CSS or Javascript
if you really want to repaint individual sections. The main problem is
that you don't want the menu and banner repainted even tho they'll be
cached...

Ben
dq5studios.com

Jul 17 '05 #3
David wrote:
everywhere I go, i get told "don't use frames, use php instead"

ok... so how do i go about it?

I want a top banner that doesn't move, and a "contents" type list on the
left (that may have a scroll bar)
and the rest of the window is the main page (obviously)
The CSS property "overflow" can be set to "scroll" to get scroll bars on
any block-level HTML element. As usual, this doesn't work on old
browsers such as IE.


now, I dont want all 3 areas to be loaded/repainted when i click a link on
the contents, just the "main area"
You can use XMLHttpRequest to update only a certain section of an HTML
document with Javascript. I found useful information on this here:
<http://jibbering.com/2002/4/httprequest.html>

Is this achievable in php?
No. PHP is server-side, but loading/repainting HTML pages is a
client-side thing.

Thanks in adavance

Jul 17 '05 #4
David wrote:
everywhere I go, i get told "don't use frames, use php instead"

ok... so how do i go about it?

I want a top banner that doesn't move, and a "contents" type list on the
left (that may have a scroll bar)
and the rest of the window is the main page (obviously)

now, I dont want all 3 areas to be loaded/repainted when i click a link on
the contents, just the "main area"

Is this achievable in php?

Thanks in adavance


Hi David,

Frames is a CLIENT side solution.
PHP only delivers the HTML the CLIENT uses.
Of course PHP does a lot more, but from the client's point of view (a
browser) this is all.
The browser doesn't see the difference between a flat HTML-page, or a very
sofisticated PHP-script that delivers the HTML.

So the advise to use PHP instead of frames doesn't make too much sense,
since PHP is typically SERVERside.

That said: Have a look at Javascript and CCS, since that technologies can
help you more with banners and such.

To show you the difference:
for example: You can easily let Javascript change a image (banner) every 30
seconds.
Where PHP comes into picture if for example: If you have 200 banners to
choose from, you can use PHP to deliver a random image:
<img src="myrandompict.php">

myrandompict.php is a simple script that returns an image from the server.

Hope that helps a bit.
Regards,
Erwin Moller
Jul 17 '05 #5
What I recommend is a trick using the php include() function

Let's say you have a layout and you have a default content area. Use
the php include function.

<?php

// Let's do this just in case there is no variable
if(!$page) include("home.php");

// Include File Based on Variable
if($page == "home") include("home.php");
if($page == "about") include("about.php");

?>

Now, make each of these files, without anything other than the content.
When linking to these pages, just type index.php?page=about, for
example to include the about page.

Hope this helps.

Jul 17 '05 #6
What I recommend is a trick using the php include() function

Let's say you have a layout and you have a default content area. Use
the php include function.

<?php

// Let's do this just in case there is no variable
if(!$page) include("home.php");

// Include File Based on Variable
if($page == "home") include("home.php");
if($page == "about") include("about.php");

?>

Now, make each of these files, without anything other than the content.
When linking to these pages, just type index.php?page=about, for
example to include the about page.

Hope this helps.

Jul 17 '05 #7
Thanks for the advice guys.
much appreciated
Jul 17 '05 #8
.oO(in************@gmail.com)
What I recommend is a trick using the php include() function

Let's say you have a layout and you have a default content area. Use
the php include function.

<?php

// Let's do this just in case there is no variable
if(!$page) include("home.php");
This line will cause a notice (set error_reporting to E_ALL on your
development machine). You should check with isset() instead.
Additionally the above relies on register_globals. Better use the
superglobal arrays $_GET, $_POST etc:

if (!isset($_GET['page'])) {
include 'home.php';
}
// Include File Based on Variable
if($page == "home") include("home.php");
if($page == "about") include("about.php");
For 10 pages you would need 10 if-statements. Consider something like
this:

$pages = array('home', 'about', ...);
if (isset($_GET['page']) && in_array($_GET['page'], $pages)) {
include $_GET['page'].'.php';
} else {
include 'home.php';
}

Also think about what will hapen if a user calls the pages directly
without your index script:

www.example.com/about.php

Will they still work as expected? Better store such files outside the
server's document root if you don't want them to be accessible directly
by an URL.
Now, make each of these files, without anything other than the content.
When linking to these pages, just type index.php?page=about, for
example to include the about page.


You should have a look at mod_rewrite to make the URLs better readable
and more search engine-friendly:

www.example.com/about/

can then be rewritten server-internally to

www.example.com/?page=about

Micha
Jul 17 '05 #9
"David" <lo********@yahoo.co.uk> wrote in message
news:41********@clear.net.nz...
everywhere I go, i get told "don't use frames, use php instead"

ok... so how do i go about it?

I want a top banner that doesn't move, and a "contents" type list on the
left (that may have a scroll bar)
and the rest of the window is the main page (obviously)

now, I dont want all 3 areas to be loaded/repainted when i click a link on
the contents, just the "main area"
That's what frames are for.
Is this achievable in php?


No.
Jul 17 '05 #10
In addition ot the PHP suggestions so far, I would also recommend
learning CSS2. These are good places to start:

http://glish.com/css/
http://www.meyerweb.com/eric/css/edge/

bblackmoor
2005-01-12
Jul 17 '05 #11
David wrote:
everywhere I go, i get told "don't use frames, use php instead"
They would have told "don't use frames, use div instead" which is a
valid point in terms of CSS based design--you can position the
container anywhere (fixed or scrollable) by just controlling the
stylesheet.
ok... so how do i go about it?

I want a top banner that doesn't move, and a "contents" type list on the left (that may have a scroll bar)
and the rest of the window is the main page (obviously)

now, I dont want all 3 areas to be loaded/repainted when i click a link on the contents, just the "main area"

Is this achievable in php?


PHP can spits out HTML or JS or anything you specify. So, PHP can do
nothing here. You cannot achieve what you wanted without using frames
or XMLHttpRequest (JS). But, usually you'll need to refresh or repaint
or rotate the banner. If your concern is about loading time and
efficiency you should use div/CSS based design instead of frames.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #12
Thanks, I'll take a look at this.
In the meantime, I am using a start page that gives the user the option of
frames.
But I am keen to try it in CSS due to other benefits
or rotate the banner. If your concern is about loading time and
efficiency you should use div/CSS based design instead of frames.

Jul 17 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by McKirahan | last post: by
6 posts views Thread by Eric Bodden | last post: by
1 post views Thread by SpamProof | last post: by
20 posts views Thread by Tammy | last post: by
10 posts views Thread by ian | last post: by
2 posts views Thread by C P | last post: by
9 posts views Thread by DaveF | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.