A
A
Andrey Plax2015-01-06 11:22:04
PHP
Andrey Plax, 2015-01-06 11:22:04

How to edit the design of a site consisting of many PHP include pageX.php?

I develop desktop applications on .Net. There was a need to write a couple of pages under the Web. I figured out palatine with PHP and even wrote a couple of simple sites. I used the classic approach from textbooks, like:

<?php include 'header.php'; ?>
<?php include 'leftmenu.php'; ?>
<?php include 'body.php'; ?>
<?php include 'rightmenu.php'; ?>
<?php include 'footer.php'; ?>

But! When it becomes necessary to correct, and sometimes seriously, the layout of the site, then you have to edit a lot of pages! Which doesn't seem right to me. I don't plan to do deep learning of PHP. I am positioned on Desktop. At least for now... Just maybe someone will tell you how to solve or where to read about BestPractics for this situation. In order not to shit-code :)
In advance, many thanks for the rational answers!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Chukhlomin, 2015-01-06
@undefine

www.phptherightway.com/#templating

G
Grigory Dikiy, 2015-01-06
@frilix

firstly, it is desirable to move to the MVC pattern, otherwise it will not only be difficult to extend, but also change the design. MVC and OOP to help you

V
Victor Golovko, 2016-12-13
@siptik

The most primitive, in your case is:
connecting these parts in the template itself:
main_template.php

...
<body>
<?php include 'header.php';
<?echo $content ?>
<?php include "footer"
</body>

In a file like demo.php:
Ideally, the controller should not know about any pieces of the template at all. One switch and that's it. The template is responsible for the template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question