Search code examples
javascriptphphtmllayoutshared

What is the best way to share a layout for multiple HTML files?


I like how in MVC you can have a _layout file in a shared folder and multiple cshtml files can use it. Is there anything similar I can do using HTML5, PHP, or Javascript? If so what's the most efficient way.

Thanks :)

Thanks. Using php files for headers/footers is exactly what I was looking for! Very simple stuff :)


Solution

  • If your Basic Layout is

    HeaderBar
    
    CONTENT
    
    FooterBar
    

    You can make 2 Files

    1. top.php:

      • Head Area with your Syles...
      • Start of the Body
    2. bottom.php

      • Footer and Javascript

    Then you can include both Files with

    <?php include '/yourfolder/top.php'; ?>
    

    It always makes sens to put the menu into an additional File, becouse otherwise you would Need to acess every singe site to Change entrys.