Do you think the menu of a dynamic web page would work? [closed]

-1

Well, I have not found a way to do it optimally on the internet and I would not like to invent something inefficient or bad structured .

Having said that, I'll explain:

In the case of having a web page with a menu bar above with different sections such as: 'Home', 'Friends', 'About ..', etc. If I'm doing it with chunks of php ... would you have to have a html for each category?

I could not use a single html and go calling different html fragments or I do not know how it would be the most optimal way, because if I did not have to make an html for each menu and submenu and I'm sure there are easier ways.

I just need to know the correct technique

    
asked by josanangel 22.07.2018 в 22:18
source

1 answer

1

If you work with php, one way to include common elements in several pages (like menus, headers, footers) is to include them in a php file and then from each of your pages you make a require

This is the structure that the pages could have (something similar):

<?php

require('./header.php');
require('./menu.php');

// Cosas...

require('./footer.php');

?>

On the other hand, if you only work with html, one way of not having to repeat certain fragments is to write them using javascript. You can load a js that has a function that is the one that writes the menu. Either by document.write or by manipulating the DOM, for example with createElement

    
answered by 22.07.2018 в 23:17