Route system in php

Asked

Viewed 2,252 times

-1

My current structure is as follows: :

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

How do I load the content in the index when the person clicks on the title without opening on another page ( ie just change the central content ), I researched about but only found things about mvc Works frame and tips to do in the simplest way and add the top and footer of the site on the other pages and link as realized in the previous image, someone would have content or explanation to help me ?

  • 1

    Do you want it to open on the same page? Don’t buy that link is and it will never, ever leave the index but will have everything you need?

  • 1

    I don’t know if it fits but in the content of the index you can load according to the value of the parameter obtained via get placed in the links. Dai faz if Else ou case e require conteudoXXX

  • 1

    Look for ajaxify jQuery.

1 answer

1


What you are wanting, in my view, could be solved quietly with the use of a include 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'; ?>

In view of the above structure, you could simply upload 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 by using the Javascript Angular JS framework.

If you use the Ngroute, can be a good solution for dynamic page loading.

Browser other questions tagged

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