Jump to content

question with page frame


thankqwerty

Recommended Posts

I have made a frame for my website, which contain some of the usual elements i.e. header, menu, .... etc.

 

At the moment i program it in the following way.

1) The frame includes "header.html" (which contain the logo.... etc) and "menu.html" which are the same for all pages, then the contents for different pages i.e. index.php, news.php, projects.php .....etc

 

2) each page, for example the index page, i need to have a file for frame-index.php which combines header.html, menu.html and index.php. Then index.php to store the actual content of the idex page.

 

3) so i need 2 files frame-index.php+index.php for the index page, and the same for the project page and news page.....etc. And if i want to change the design of the frame i'll have to change each of the frame-XXXX.php files. Which doesn't seem very efficient to me.

 

What would be the better way?

Link to comment
Share on other sites

You could have a main.php file which will be the only file that will be accessed by the user. This file would receive a page name in it's url, meaning through GET, and it will display it with the other frames. Basically it should look like that:

 

<?php

if(!isset($_GET['page']) || $_GET['page'] == ""))
$page = "error.html";
//You have to check that the page name given is a valid filename
//and that it's a file from your pages- you don't want to 
// include some kind of virus or malicious code by mistake...
if($_GET['page'] is invalid in some other way)
$page = "error.html";
?>

<frameset>
<frame ...> //menu, header and everything else you want
<frame src="<?php echo $page; ?>"> //This will include the wanted page
</frameset>

 

You'll have to create an "error.html" page for invalid requests.

This way, your navigation would be something like this- if you want to create a link to index.php, you'd link to main?page=index.php

Of course there are ways to clean up this mess using mod-rewrite, but the example above gives the basic concept.

 

Orio.

Link to comment
Share on other sites

Thank for the reply.

 

In that case would it be better to use session?

So i click something in the menu which pass the requested page to session, and i can avoid leaving a mess in the URL. But if i'm leaving the URL clean is that means i won't able to use mod-rewrite later (after i learn it ><!) to give each of the page a clearier URL. (i suppose if i use session all the link would appear to be main.php, instead of index.php or news.php or project.php). Is that mean if i'm going to use mod-rewrite later i should stand the mess in the URL for now?

Link to comment
Share on other sites

This has nothing to do with sessions.. Sessions are used to carry information from page to page, but requests cannot be made thru those.

Using mod-rewrite you could have your users accessing urls such as news.php but that would be phrased as if they've accessed main.php?page=news.php. So all of the mess would be gone. That doesn't mean that behind the scenes the structure would change. You'll still need to have main.php to channel all of the requests.

 

Orio.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.