Yes, there is also Javascript 🙂 I avoid that when I can just because I can never justify the time spent troubleshooting for various browsers, and in the case I described above, I realized the problem very early on and was able to build the app with the frames issue in mind.
So anyway, in response to this question:
I understand what this is trying to do, but when the target is set to "_top" does that refresh all of the windows?
Also, can you explain the different parts of the initial if condition and how it knows the different parts of the URL.
Yes, the target will make all the frames refresh. For me this was not an issue as my status bar was basically just text. If one of your frames is image heavy or complex in another way, it may make page reloads slow.
And again, you have to make each default frame page (in the example above they would be status.php, navigation.php, and content.php) aware that they will be getting called on when you have to reload the frames (using the method I described), so they can act accordingly.
What I mean by that is when the frameset is first loaded, you have the main frameset page, perhaps index.php, and then you have the first three pages to get loaded, status.php, navigation.php, and content.php. If your site is how I think it is, the page that lists the users is not going to be the first page from the content frame. Maybe it will be called users.php or something. In my scenario, content.php needs to know that it may be receiving a GET request that originated not from itself, but from another page, and then either forward the data onto that page, or handle it in some appropriate manner.
Just to make it entirely clear how it worked in my case: I actually had the whole site navigation setup as an SQL db. So the whole site actually consisted of index.php (the frameset), status.php (the top frame), nav.php (the navigation bar), and content.php (the main content page). Then I set up a simple database with parent/child relationships between different "pages" on the site, to form a hierarchy, like so:
-
itemNum <-- inique ID for each "page"
-
parent <-- itemNum of the item that is this items parent, 0 is top level
-
title <-- display name for this item
-
link <-- the actual page if this is indeed a page (more on that)
Here is a sample set of data from that db:
(itemNum){parent} title - link
(1){0} User Management - menu://
(2){0} Site Management - menu://
(3){0} File Management - menu://
(4){1} Add User - ./inc/addUser.php
(5){1} Edit User - ./inc/editUser.php
(6){2} New Page - ./inc/newPage.php
(7){2} New Dir - ./inc/newDir.php
(8){2} Edit Page - ./inc/editPage.php
(9){3} Delete File - ./inc/delFile.php
Now, when the application was initiated (when a user logs in), the system forms a heirarchal list of all the whole site. An example using the above would look like this:
User Management
-> Add User
-> Edit User
Site Management
-> New Page
-> New Dir
-> Edit Page
File Management
-> Delete File
Do you see the pattern? The parent/child relationship in the db allows for fairly complex nesting. This also allows me to make a "bread crumb" navigation aid with amazing ease, as well as provide a fully web based management system for access, structure, etc. Think of which individual page like addUser.php and delFile.php as a simple system tool, there for basically one function. The database structuring then allows you to tie all these tools together with a consistent and easy to change interface.
Now, there are two other db tables, users and security, that are used to check that someone accessing any of the pages is logged in and allowed to access whatever page it is they are loading, you'll see why in a second.
You will notice that the links for the various pages are sometimes menu:// or sometimes ./inc/sompage.php. When the application first puts the structure together, it looks at the link to determine if that item is actually just a link to another group of options or an actual option with a function. So, my site really does have a ton of pages, but I have content.php setup to look for certain variables that are in each query string, that tells content.php that this page id was called. That page can then look at the corresponding link in the db. If it sees menu://, it pulls all the child elements and presents them as further links deeper into the site. If it sees the location of a valid file, it will display that file instead.
I actually made the site so that there are only two instances where all the framed needed to be reloaded, once when the user logged in, and once when they logged out. The status bar would change to reflect that they were logged in, and provide a logout link, and also showed what user group they were in. The navigation bar would show only the menu choices that they had access to, and did not need to change while they used the application (which is where yours differs the most I think).
So, that was rather long winded, but I guess I felt like I just wasn't explaining it right without telling how I used it. Now, in your case, you are posting to a page that then shows a list of links. These links need to update content in two frames. So, you need to call on the frame page, using its url and target="_top" (or alternately use the JavaScript method) so that it can then pass the data to both the content and nav frames. Whatever nav page that your frameset calls needs to know that it may be receiving GET vars that will cause it to alter its normal behavior.
What you see happening in my frameset example above is first the script looks for the presence of $GET variables { if ($GET) }. If it finds these, it will first set a little counter variable ($i) to 0, and then proceed to loop through all of the $GET vars. On the very first one ($i == 0), it starts the string its builds with a ? followed by the name of the variable = value of the variable. It then increments the counter by one ($i++), On every successive loop ($i != 0) it just concatenates an & and the name of the variable = the value of the variable. The script knows what the $GET vars are because when you call that frameset page using target="_top" you are using a url that says something like:
<a href="index.php?var1=val1&var2=val2..." target="_top">
where those vars and vals are all the data you need to pass to both the nav and content pages.
Then, as it starts the HTML output, it tacks on "?var1=val1&var2=val2..." to the end of the urls on the frame pages. This allows this data to pass to those pages. Now, in your case, where I suspect that just reloading the main frame page will cause the wrong page to be loaded in the content frame, you may need to add some logic to the framepage itself that watches for particular variables, and dynamically loads the appropriate frame pages in their respective frames.
phew That was a lot of writing. Again, if I am not clear, please do not hesitate ask. Hope this helps 🙂