Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

What's the standard way to keep the same menu on top among different web pages without having to duplicate it on each page (I don't mean that it doesn't reload like when using frames and only loading the bottom part; I want the menu to scroll with the page when scrolling down, like this, this, this and pretty much every single web page that exists). I found this answer but the guy can't use Php and I can. Plus, I see several people giving different suggestions, but I assume there is a standard since pretty much every single web page in the whole web have a menu on top that stays the same among multiple pages . I'm just a newbie on web design (I can program Php and Html easily but I have no idea about standards and stuff like that since I'm self-taught guy ;)).

What I would normally do is to include the menu with php but I'm not sure if this is the "standard".

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

It is pretty simple, but in case you're still having trouble, the most basic way to do it is to just use include() or require() to include the menu file at that particular location of the document.

However, if you're already thinking of things in terms of maintainability and best practices, then you should probably just be using a templating system. So you'd have a template with your header and footer that includes the various reusable components and spits out your content in between.

If you don't know how to set something like this up, I'd just look into the various MVC frameworks out there (e.g. CakePHP). Using an MVC pattern (or something comparable) that separates your flow logic, business logic, and presentational code is another best practice. This is far better than having a bunch of individual pages with the same include/require statements, duplicate HTML, and having all of your code mixed in together.

share|improve this answer
add comment

There is no standard. Do it however is best for you. I'd elaborate but I really think it is that simple. This seems like a case of over thinking something that is really as simple as it seems. :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.