How to call menu inside another file

Asked

Viewed 48 times

-2

I want to call a menu file done in html, inside another html file to reuse the code without having to type everything again for each module of the menu. Do I have to use PHP to do this? Follow the code below:

<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="robots" content="noindex,nofollow">

<title> Painel administrativo </title>

<!-- Favicon -->
<link rel="icon" type="image/png" sizes="16x16" href="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/images/favicon.png">
<!-- Bootstrap CSS -->
<link href="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Menu CSS -->
<link href="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
<!-- Menu CSS -->
<link href="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/morrisjs/morris.css" rel="stylesheet">
<link href="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/css/style.css" rel="stylesheet">

<!-- JS and jQuery -->

<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Menu Plugin JavaScript -->
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/metisMenu/dist/metisMenu.min.js"></script>
<!--Nice scroll JavaScript -->
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/js/jquery.nicescroll.js"></script>
<!--Morris JavaScript -->
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/raphael/raphael-min.js"></script>
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/bower_components/morrisjs/morris.js"></script>
<!--Efeitos no menu -->
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/js/waves.js"></script>
<!-- Tema padrão do admin -->
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/js/myadmin.js"></script>
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/js/dashboard1.js"></script>
<script src="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_login/controller/logoff.js"> </script>
  Administration
  • SIR Steakhouse
  •         </nav>
            <div class="navbar-default sidebar nicescroll" role="navigation">
                <div class="sidebar-nav navbar-collapse ">
                    <ul class="nav" id="side-menu">
                        <li class="sidebar-search hidden-sm hidden-md hidden-lg">
                            <div class="input-group custom-search-form">
                                <input type="text" class="form-control" placeholder="Search...">
                                <span class="input-group-btn">
                                    <button class="btn btn-default" type="button"><i class="ti-search"></i> </button>
                                </span>
                            </div>
                        </li>
                        <li>
                            <a href="dashboard.html" class="waves-effect"><i class="glyphicon glyphicon-fire fa-fw"></i>
                            Dashboard</a>
                        </li>
    
                        <li>
                            <a href="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_admin/cad_option.html" class="waves-effect"><i class="ti-layout fa-fw"></i>Cadastros</a>
                        </li>
    
                        <li>
                            <a href="#" class="waves-effect"><i class="ti-info fa-fw"></i>Informações</a>
                        </li>
                        <li> 
                            <a href="C:/Desenvolvimento/Projeto_ChatBot/Version1.1/modulo_login/views/login.html" onclick="return logoff();" class="waves-effect"><i class="ti-power-off fa-fw"></i>Sair</a>
                        </li>
                    </ul>
                    
                    <div class="center p-20">
    
                    </div>
                </div>
                <!-- /.sidebar-collapse -->
            </div>
    
            <!-- Page Content -->
            <div id="page-wrapper">
                <div class="container-fluid">
                    <div class="row bg-title">
                        <div class="col-lg-12">
                            <h4 class="page-title"></h4> 
                            <ol class="breadcrumb">
    
                            </ol>
                        </div>
                        <!-- /.col-lg-12 -->
                    </div>
                    <!-- /.row -->
    
    
    
                    <!-- row -->
                    <div class="row">
                        <div class="col-md-6 col-xs-12 col-sm-12">
    
                        </div>
                    </div>
    
                </div>
    
            </div>
    
            <footer class="footer text-center"> 2021 &copy; Todos os direitos reservados <a
                href="dashboard.html">SIR Steakhouse</a> </footer>
            </div>   
    
        </body>
        </html>
    

    1 answer

    0

    Opa, yes, with php would be a good one, you can create a reusable "component". Hence would have your file menu.php and would include him wherever he wanted to. But for this to work, it couldn’t be in a file .html

    In your dad file and stuff:

    <html>
      <body>
        <?php require 'menu.php' ?>
      </body>
     </html>
    

    Hence, if you have html inside the included file, it will be reused on the screen =)

    Browser other questions tagged

    You are not signed in. Login or sign up in order to post.