pull site structure through the database

0

I have a doubt I have a fairly large site where a section of the site often repeats itself where the structure and equal on all pages what changes is the content that is pulled by the database most wanted to know if I can by the hmlt php structure inside the database because if I want for example a divi or any other element I'll edit it page by page so it would be better to create the page and pull its HTML structure through the database there so all the others would change too

    
asked by anonymous 31.08.2016 / 22:43

2 answers

2

In particular I prefer to create a master page with the html structure and give an include in the other pages.

<--Estrutura da pagina mestre-->

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!-- Imprime o titulo da pagina filho -->
    <title>Página Mestre | <?php echo $titulo; ?></title>
</head>
<body>
    <!-- Menu -->
    <nav></nav>

    <!-- Conteudo da pgina filho -->
    <?php echo $conteudo; ?>

    <!-- Roda Pé -->
    <footer></footer>
</body>

<-- Página filho -->

<?php ob_start(); ?>

<!-- Conteudo da pagina filho vai aqui -->

<?php
$conteudo = ob_get_contents();
ob_end_clean();
// Titulo da pagina filho
$titulo = 'Home';
// Include da página mestre
include_once 'pagina_mestre.phtml';
    
31.08.2016 / 23:00
1

You do not need to use a database, just use include or include_once, which aims at php is "bring the text from another file" to the page where the include was used. Then you can take these repeating files and add them to other pages, and when you want to edit, edit this separate file.

    
31.08.2016 / 23:01