Mobile app version of vmapp.org
Login or Join
Tiffany637

: Most standard / Best way to keep the same top menu among different web pages? What's the standard way to keep the same menu on top among different web pages without having to duplicate it

@Tiffany637

Posted in: #Html #Php #Standards

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".

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Tiffany637

2 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

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.

10% popularity Vote Up Vote Down


 

@Pope3001725

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. :)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme