PDA

View Full Version : Redirect of treemenu


froggy
May 30th, 2007, 15:30
At the suggestion of several people, I went ahead and used Sothink's Treemenu to put a navigation menu on the side of my page.

Overall, I was pretty happy with the menu except that it couldn't track the active page. Well, Sothink's latest update fixed that problem and the treemenu now tracks the active page and modifies the menu accordingly. As near as I can tell it does its tracking by reading the url in the address bar and verifying that address against all of the URLs in its menu. Then it highlights the menu accordingly.

The problem comes in with default pages. For example, if the menu has a "Home" link at "www.webpage.com/index.html" it won't highlight the menu item if the url in the address bar reads "www.webpage.com".

I'm trying to work out a way to make the default page reload itself once to show the full url.

I tried tucking this in at the top of the page:

<meta http-equiv="refresh" content="5; url=index.php?home">

but it just kept refreshing the page every five seconds. It did put the full url into the address bar after the first time, but it became too memory intensive and annoying to read.

How would I do the something similar, but only once?

Corey Bryant
May 30th, 2007, 17:27
If you put that meta tag in there, it's going to fresh. Can you make the home page go to index.php?home2 and then put that refresh tag in that page to direct over to index.php?home?

Or use some type of rewrite possibly?

froggy
May 30th, 2007, 18:18
I think my best bet is probably a rewrite, Corey. I've tried to minimize redirects. Too much processing time.

I am using css frames and a php include for the content "frame". I can't remember the exact logic behind every line, but perhaps there is another snippet I can add to this section of code that'll serve my purposes?

<?php
if($_GET['page'] != '') {
$page = $_GET['page'];
} elseif($_SERVER['QUERY_STRING'] != '') {
$page = $_SERVER['QUERY_STRING'];
} else {
$page = 'home';
}

$path = "php/$page.php";
$error = 'php/error.php';

if(file_exists($path)) {
include $path;
} else {
include $error;
}
?>

inimino
May 30th, 2007, 20:08
Why not point the links in the menu to the cleaner, shorter, neater URL http://www.example.com/ ? There's really no need to have extraneous cruft on the end of the URL.

Your new best friend: <a href="/">Home</a>

froggy
May 30th, 2007, 21:07
Such an elegant, simple solution!! Thank you!

inimino
May 31st, 2007, 00:33
You're welcome!