Modular web in PHP .. I update the whole page, what is the best way to do it?

0

I have this code:

<?php include("FOLDER1/archivos/MENU.php"); ?>

<?PHP
if (isset($_GET['id'])) {
if (!empty($_GET['id']) && $_GET['id'] != "index") {
    if (file_exists("./FOLDER1/".$_GET['id'].".php")) {
        include ("./FOLDER1/".$_GET['id'].".php");
    } else {
        echo "La pagina que estas buscando no existe";
    }
} else {
    include ("FOLDER1/inicio.php");
}
} else {
include ("FOLDER1/inicio.php");
}
?>
<?php include("FOLDER1/archivos/footer.php"); ?>

I will explain its use. when loading in my index the 3 parts, I have to in MENU.php apart from having the additional keypad immediately I have an animation (music) .. load the page and shows everything but when I click any section of the menu .. if I load the php sheet page requested, but the animation (music) starts again .. it is supposed that only the menu selected should be refreshed .. that is why I say that not only is what you ask for, but the whole page and where I detect it is in the music that starts again and it is assumed that in a web page modulated in PHP should not happen that is what comes to replace iFrames .. I hope you have understood .. Thank you.

    
asked by Rick 21.11.2016 в 21:59
source

1 answer

0

If I understand it well, it is "modulated" but structurally, by the fact of using include() but this happens on the server side, not on the browser side. In fact, every time you click on a link and the browser URL changes, the browser makes a request HTTP to the server ( request ), this resolves the route and places the destination, if it is a PHP file, what interprets (with all its include s, conditional, etc) and converts it into a plain HTML that the browser can understand and finally sends it to the client ( response ).

For the behavior you are looking for, you may need to use iframes or a frontend library to do this work on the browser side (modularize views, reactive interfaces, etc.) as > Angularjs , Reactjs , Vuejs , etc. Do it yourself by ajax .

    
answered by 21.11.2016 / 23:02
source