Route system in php

-1

My current structure is as follows:

How do I load the content in the index when the person clicks the title without opening another page (or just change the central content), I looked into but only found things about frame works mvc and tips to do it the way simple and add the top and footer of the site in the other pages and link as done in the previous image, would anyone have content or explanation to help me?

    
asked by anonymous 25.02.2017 / 04:25

1 answer

1

What you want, I think, could be solved with the use of a% dynamic%.

You can do something like this:

<?php include 'topo.php'; ?>

 <?php 
        $pagina = filter_input(INPUT_GET, 'pagina');
        // faça um tratamento em "pagina" pra evitar qualquer ataque malicioso
        include 'paginas/' . $pagina '.php';    
 ?>    
<?php include 'footer.php'; ?>

Given the structure above, you could simply load a page, create links like this:

 http://meusite.com.br/?pagina=home
 http://meusite.com.br/?pagina=sobre
 http://meusite.com.br/?pagina=contato

By default, if you want to load "home" without anything being passed, you can make this small change:

$pagina = filter_input(INPUT_GET, 'pagina') ?: 'home';

There are also other cool ways to do this, which is using the JS Angular Javascript framework.

If you use NgRoute , it can be a good solution for dynamic page loading.

    
25.02.2017 / 16:23