More help with PHP menus? 2nd level ideas. (OT to some).

M

Mike Barnard

Hi again.

[For those of you that think PHP is off topic, sorry, but this has
been the best forum for help I have found so far and I have been
invited to continue to discuss this subject here.]

Bootnic offered me a simple PHP menu include which is fantastic.
Thanks again. I have been trying to improve on it by adding a second
level of menus. However, I am very new to PHP and I can't decide on
which is the best methodology to do it.

Obviously, the PHP script is only processed when the page is requested
from the server. Therefore, in order to have a second level of menus
show when a user hovers over a first level menu item, the browser has
to do the work in showing it. This removes PHP itself from the agenda
at this stage.

Javascript would be one way I'm sure and there are loads of such
systems available for use. But I don't trust that all browserss will
have JS running so I wish to rely on PHP, HTML and CSS.

The only way I can think of for a second ( or more?) level to work
with these restrictions is for the menus for *ALL* levels to be
created by the PHP script when the page is called, but the CSS
properties of the unwanted lists be set such that they can't be seen.
Maybe by absolute positioning, sending them off screen until a hover
changes thier locations, or by setting thier colours to transparent or
something, or maybe using Z indexs to hide them under the rest. Or
something else?

I do not want to reinvent the wheel. I wonder if someone can help by
explaining the most efficient methodology, and why it is. I'm happy to
try and create my own scripts, I do not expect it to be handed to me
on a plate, but I do not have enough knowledge and experience to get
the best from this without some advice. If anyone would like to take
the time to comment (nicely!) I would really apprecieate it.

Thanks, again.

Mike.
 
M

Mike Barnard

Hi again.

[For those of you that think PHP is off topic, sorry, but this has
been the best forum for help I have found so far and I have been
invited to continue to discuss this subject here.]

Bootnic offered me a simple PHP menu include which is fantastic.
Thanks again. I have been trying to improve on it by adding a second
level of menus. However, I am very new to PHP and I can't decide on
which is the best methodology to do it.

In another forum it has been sugessted that Javascript is a more
reliable way to go. This article was pointed out to me.

http://www.howtocreate.co.uk/tutorials/testMenu.html

1. How many users will fail because they have no javascript allowed
compared to those who don't have browsers modern enough to use pure
css menus?

2. How does this hang in with the original intention, of having a
SINGLE menu file that gets included on the page html?

PHP / CSS or Javascript too? What is the consensus please?
 
B

BootNic

[snip comments on expanding menus & PHP]

It's time for you to provide a url. If you do not have a host you may
find a free host.

http://www.leadhoster.com/signup.html

The above url is one place where you may get a free host that offers php
and no adds. Apache version 1 something and php version 4 something. It
also has FTP access.

Once set up you may build a mock-up of what your website may look like,
in this case a mock-up of your menu and directory structure.

For the newsgroups keep it bare as possible, only what is required for
your current discussion.

For your menu or site navigation, I think the most important part is a
sitemap. A link to your sitemap on every page.

Expanding menus. I suggest you not do any kind of expanding menu. What I
suggest is that you expand your current directory, which can be done with
php. That can be discussed more after you get a mock-up site set up, with
a sitemap and menus in place.

Google is your friend, you may search the newsgroups for discussion on
the use of expanding menus.

Regardless of what path you take with your menu, build your mock-up, in
that way more will likely offer comments or help.
 
E

Ed Mullen

Mike said:
Hi again.

[For those of you that think PHP is off topic, sorry, but this has
been the best forum for help I have found so far and I have been
invited to continue to discuss this subject here.]

Bootnic offered me a simple PHP menu include which is fantastic.
Thanks again. I have been trying to improve on it by adding a second
level of menus. However, I am very new to PHP and I can't decide on
which is the best methodology to do it.

Obviously, the PHP script is only processed when the page is requested
from the server. Therefore, in order to have a second level of menus
show when a user hovers over a first level menu item, the browser has
to do the work in showing it. This removes PHP itself from the agenda
at this stage.

Javascript would be one way I'm sure and there are loads of such
systems available for use. But I don't trust that all browserss will
have JS running so I wish to rely on PHP, HTML and CSS.

The only way I can think of for a second ( or more?) level to work
with these restrictions is for the menus for *ALL* levels to be
created by the PHP script when the page is called, but the CSS
properties of the unwanted lists be set such that they can't be seen.
Maybe by absolute positioning, sending them off screen until a hover
changes thier locations, or by setting thier colours to transparent or
something, or maybe using Z indexs to hide them under the rest. Or
something else?

The menu system on my site uses two levels in some parts. It is
included into each of the 200+ pages via a server-side PHP include:

<?php include("./styles/menu.txt"); ?>

Go to link below and View Source to see all the menu code.

You can also see the CSS styling of the menu in:

http://edmullen.net/styles/default.css

and the actual menu file at:

http://edmullen.net/styles/menu.txt

The system is from:

http://www.tanfa.co.uk/css/examples/menu/tutorial-h.asp

Not saying it's the best one but it does work.
 
D

dorayme

Mike Barnard said:
Hi again.

[For those of you that think PHP is off topic, sorry, but this has
been the best forum for help I have found so far and I have been
invited to continue to discuss this subject here.]

Bootnic offered me a simple PHP menu include which is fantastic.
Thanks again. I have been trying to improve on it by adding a second
level of menus. However, I am very new to PHP and I can't decide on
which is the best methodology to do it.

I am surprised you are so keen to race so far ahead. There are
downsides to multi-level menus that should surely put them on the
back-burner till you get other things well on your site.

What have you done about your wife's hat or the logo? <g>

What about the basics, you happy with it yet?
 
M

Mike Barnard

[snip comments on expanding menus & PHP]

Good afternoon. (For me here in the UK.)
It's time for you to provide a url.
www.thermachek.com/temp/index.php

Once set up you may build a mock-up of what your website may look like,
in this case a mock-up of your menu and directory structure.

More than a mockup, but a lot to be filled in yet. As the PHP stuff is
processed, it means that you cannot see the code. Therefore it is cut
n pasted at the end of this message.
For your menu or site navigation, I think the most important part is a
sitemap. A link to your sitemap on every page.

Its not totally defined yet. You will see from the above link that the
'home' link is not yet styled. I want to add a second layer of menus
to the items titled "The Law" and "Guides for...".
Expanding menus. I suggest you not do any kind of expanding menu. What I
suggest is that you expand your current directory, which can be done with
php. That can be discussed more after you get a mock-up site set up, with
a sitemap and menus in place.

I don't understand the difference between an expanding menu and an
expanding directory. A google search for both shows that I understand
(and want, ideally) expanding menus but makes no sense of expanding
directories.
Google is your friend,

I spend a lot of time hand in hand with my mate Google.
you may search the newsgroups for discussion on
the use of expanding menus.

I have done. Many thanks for you attempts to educate me. :)

Mike.





***The PHP ***

The code in the index.php file is simply an include to the menu file.
<?php include('mainmenu.php');?>

The mainmenu.php file itself consists of the following. It is your
script with slight alterations and notes to myself on how it works. It
looks MUCH tidier in my version of NoteTabPro, It has not cut n pasted
perfectly.


<ul id="navlist">

<?php

//Menu array. Builds the array and puts the page names and keys in.
//The left item is the 'key', the right the array content.
$menu = array
(
"/index.php" => "Home",
"/law.php" => "The Law",
"/glossary.php" => "Glossary of terms",
"/selfassess.php" => "Guides for self assessment",
"/hireme.php" => "Hire a professional assessor",
"/contact.php" => "Contact me",
"/Links.php" => "Useful links",
"/Disclaimer.php" => "Disclaimer",
);


// Get the name of the current page.
// Contains the current script's path.
$full_path_of_page = $_SERVER["SCRIPT_NAME"];

// For testing purposes
echo "The variable \$full_path_of_page is holding the value of: ";
echo $full_path_of_page;

// Shorten it to the last forward slash and characters to its
right, the actual file
// name without the path.
$current_page = strrchr($full_path_of_page,"/");

// For testing purposes
echo "<br>";echo "<br>";
echo "The variable \$current_page is holding the value of: ";
echo $current_page;

//Build menu items
//foreach loops over the array given by array expression [$menu]. On
each loop, php looks at the $key element of the
//array, takes the content of the $key and places it into $value.

foreach ($menu as $key => $value) //Counts through the
loop.
{
echo " <li>\n"; //Creates the first part
of an HTML list item.
if ($key === $current_page) //If the item is the
current page then...
{
echo " <span>$value</span>\n"; //...just display a text with no
anchor
}
else //But if the item is NOT the current page...
{
echo " <a href=\"$key\">$value</a>\n"; //...then display an anchor
pointing to the page.
}
echo " </li>\n"; //Finish the HTML <li>
}
?>
</ul>
 
M

Mike Barnard

Mike Barnard wrote:

Hi Ed.
The menu system on my site uses two levels in some parts. It is
included into each of the 200+ pages via a server-side PHP include:

<?php include("./styles/menu.txt"); ?>

Go to link below and View Source to see all the menu code.

You can also see the CSS styling of the menu in:

http://edmullen.net/styles/default.css

and the actual menu file at:

http://edmullen.net/styles/menu.txt

The system is from:

http://www.tanfa.co.uk/css/examples/menu/tutorial-h.asp

Not saying it's the best one but it does work.

Thanks for the help. Thats the effect I'm looking for, but I didn't
know how I could include the menu files the way you have done. It
may *BE* the best, I wouldn't know, but as long as it works on the
vast majority of the browsers out there who cares about it being
'best'. Cheers.
 
M

Mike Barnard

Mike Barnard said:
Hi again.

[For those of you that think PHP is off topic, sorry, but this has
been the best forum for help I have found so far and I have been
invited to continue to discuss this subject here.]

Bootnic offered me a simple PHP menu include which is fantastic.
Thanks again. I have been trying to improve on it by adding a second
level of menus. However, I am very new to PHP and I can't decide on
which is the best methodology to do it.

I am surprised you are so keen to race so far ahead. There are
downsides to multi-level menus that should surely put them on the
back-burner till you get other things well on your site.

Hi again.

Race ahead? :) This should have been finished ages ago. I spend too
much time fiddling about and not enough working! I play Battlefield
2142 online too. Sad at my age! :)
What have you done about your wife's hat or the logo? <g>

The hat? I'm missing something here. Dr. Suess has a Cat in a Hat.
Maybe I should re read my posts! But the logo is on its way.
logoguru.co.uk have provided me with some stuff. The final version
should be with me soon.
What about the basics, you happy with it yet?

It's still very 'blocky'. I don't think it looks as 'professional' as
it could, but I'm not a professional. I think it needs a few corners
rounding off maybe? A bit more colour or maybe a *little* bit of
movement from a flash item. The main layout is OK.

I just have to get into my course notes and get more CONTENT in there.
 
D

dorayme

Mike Barnard said:
Hi again.

Race ahead? :) This should have been finished ages ago.

Yes, race ahead of the basics. If you concentrated on them you
might be finished by now. Leave nth level menus till the very
last (when you might decide, nah, who needs them, lets get this
launched and get some dough coming in). On your site I doubt
levels in menus is going to help fatten the purse. They often
don't work right anyway, especially if you are not very good at
them and know all the pitfalls, and the result may be that the
potential customer will think, is this guy going to get the
basics right on my fire risks?
The hat? I'm missing something here. Dr. Suess has a Cat in a Hat.
Maybe I should re read my posts!

"Anyway, what you have at this moment (7.43 am Sydney) looks ok
in FF, but not in Safari where the blue slides *over* the fire
helmet(?)logo". said I once.

and you said in reply:

"Thats an eye that is. To be precise, my wifes right eye. Just a
filler but an eye with flames reflected in the whites is what I
(think I) want eventually".

And my memory got to work on this in the meantime and it turned
into your wife's hat. Perhaps I should offer you an apology. Or
perhaps I should just tell you a dream I had once:

I had a cat and I wanted a dog but my mum said the dog would eat
the cat so no, we could not get a dog. One night I dreamed I had
a big tabby dog. I kid you not!

Or perhaps I should write our exchange up here as "The Martian
that Mistook an Earthling's Wife's Eye for a Hat". (Mike, don't
ask why said:
It's still very 'blocky'. I don't think it looks as 'professional' as
it could, but I'm not a professional. I think it needs a few corners
rounding off maybe? A bit more colour or maybe a *little* bit of
movement from a flash item. The main layout is OK.

Don't worry about blocky, about round corners. I suggest there
are priorities in these things and 2nd level menus and rounded
corners are not them.

Fix all the basics up, like get it to validate, get the css free
of all mistakes, get the search input field not to overrun the
navigation area where you have it or move it where it has more
room. Don't be fooled into thinking that aesthetics is primarily
about surface. With a website, it is about function as much.

Get that picture of you off the page before messing with rounded
corners. Get a nice picture of you and stop fooling about. Be
like me, serious, dedicated, no nonsense.

Don't babble.
 
M

Mike Barnard

Get a nice picture of you and stop fooling about. Be
like me, serious, dedicated, no nonsense.

Don't babble.

LOL! You don't want to see me looking 'official'. It's awful!
 
M

Mike Barnard

Yes, race ahead of the basics. If you concentrated on them you
might be finished by now. Leave nth level menus till the very

To me tha basics was to get a 'template' page in place so that I can
change the content and fill in others. Now, I've just about got it. I
HAVE THE MENU!
last (when you might decide, nah, who needs them, lets get this
launched and get some dough coming in). On your site I doubt

YES YES YES! Money, slobber.
levels in menus is going to help fatten the purse. They often
don't work right anyway, especially if you are not very good at
them and know all the pitfalls, and the result may be that the
potential customer will think, is this guy going to get the
basics right on my fire risks?

I understand all this. Thats why I'm trying to get it right.
"Anyway, what you have at this moment (7.43 am Sydney) looks ok
in FF, but not in Safari where the blue slides *over* the fire
helmet(?)logo". said I once.

Aha, THAT hat! I still have it somewhere. I think I'll include it
snekily in the site somewhere like an easter egg. You'll have to find
it.
Perhaps I should offer you an apology. Or

Lord no.
perhaps I should just tell you a dream I had once:

Janet hates it when I tell her about the wierd dreams I have.
I had a cat and I wanted a dog but my mum said the dog would eat
the cat so no, we could not get a dog. One night I dreamed I had
a big tabby dog. I kid you not!

I believe you. I rarely remember my dreams, but when I do they're very
wierd.
Or perhaps I should write our exchange up here as "The Martian
that Mistook an Earthling's Wife's Eye for a Hat". (Mike, don't
ask why, just see <http://tinyurl.com/3322ue>)

A book by Stephen D. The lost mariner. Thats me that is! Only I
wasn't around in WWII.
Don't worry about blocky, about round corners. I suggest there
are priorities in these things and 2nd level menus and rounded
corners are not them.

But (Hmmm, I say that a lot!) I want to get one good looking template
page BEFORE I start making dozens of clones of it. If I add a rounded
corner next week I'll have to add it to dozens of pages. Maybe. Aha,
thats where includes comes in to play! I wonder what amount of a page
can be constructed from includes? I may be playing late into the
night.
Fix all the basics up, like get it to validate, get the css free

At the moment it does, both css and html.
of all mistakes, get the search input field not to overrun the
navigation area where you have it or move it where it has more

It doesn't... <checks in different browsers!>... does it?

OK in Opera.
A bit of extra padding above the footer in IE7.
OK in Firefox.
Tried to download Safari. Latest beta crashes every time I try to run
it. BUT! Now I now have a trial of desktop rabbits!
room. Don't be fooled into thinking that aesthetics is primarily
about surface. With a website, it is about function as much.

Function is absolute, I agree.
Get that picture of you off the page before messing with rounded
corners.

But whats wrong with it?
Get a nice picture of you and stop fooling about. Be
like me, serious, dedicated, no nonsense.
Hmmmmm.

Don't babble.

I have a new version. Well, that is to say an updated menu version.
Wotyer think?
 
M

Mike Barnard

You can also see the CSS styling of the menu in:

http://edmullen.net/styles/default.css

and the actual menu file at:

http://edmullen.net/styles/menu.txt

The system is from:

http://www.tanfa.co.uk/css/examples/menu/tutorial-h.asp

Not saying it's the best one but it does work.

For me too! Thanks for the input. I have used this to get a basic
menu working. I just wonder how it works in older browsers as my
machine is up to date like that.

www.thermachek.com/temp/

I have looked at this way of menuing before, but it was the copying to
each page that got to me. Now I see I can INCLUDE the menu... oh
bliss. I can play now.

Thanks.
 
M

Mike Barnard

On Sun, 16 Mar 2008 14:39:49 +0000 (UTC), BootNic

I have a working menu now, thanks. Unless its broken of course. Time
will tell.

Thanks for your help.
 
E

Ed Mullen

Mike said:
For me too! Thanks for the input. I have used this to get a basic
menu working. I just wonder how it works in older browsers as my
machine is up to date like that.

www.thermachek.com/temp/

I have looked at this way of menuing before, but it was the copying to
each page that got to me. Now I see I can INCLUDE the menu... oh
bliss. I can play now.

Thanks.

Mike, it should work fine in IE7 and all current Mozilla-based browsers.
There is a hack to handle IE6 which is detailed on the tanfa Web site.
I load the iehtc file via PHP include thusly:

<?php include("./styles/iehtc.txt"); ?>

That comes before the include statement for the menu.txt file.

If you want to see the raw file code prior to when the PHP includes load:

http://edmullen.net/index.html.txt

I know it handles IE6 fine. Can't speak to IE5 and below but, frankly,
I don't care. Yes, I know there are people out there browsing with
ten-year-old software. Sorry, I have to draw the line somewhere.

As for your state of bliss, well, anything I can do to help! ;-)
 
D

dorayme

Mike Barnard said:
To me tha basics was to get a 'template' page in place so that I can
change the content and fill in others. Now, I've just about got it. I
HAVE THE MENU!

If you are learning how to get a page out that is respectable,
you should be talking a simple template that works, not a fancy
one that is very hard for you.

<http://members.optusnet.com.au/debramcalister/alt/mikeB/firefox.p
ng>

<http://members.optusnet.com.au/debramcalister/alt/mikeB/andthisin
firefoxtoo.png>

<http://members.optusnet.com.au/debramcalister/alt/mikeB/well.png>

Multilevel menus for a small site like yours is a waste of your
time when there is more fundamental work to be done. Is there
something about this that you are not understanding? (I know, you
want a multi-level menu. You want it. I know).
I understand all this. Thats why I'm trying to get it right.

You understand that they are tricky technical beasts, but not
that they have other problems (google, look up the archives of
this group) or that there are more important important things to
concentrate on in your site.

Is it ok to be frank with you?
 
D

dorayme

Ed Mullen said:
Shouldn't you just be "dorayme" with him?

No room I am afraid, I am Bob and Ted and Carol and Alice. That
is a handful enough for any one being to be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top