Answer the question
In order to leave comments, you need to log in
How to make "modular" cms?
I am writing my own cms, learning, using the fatfree framework, using this guide I made mvc https://foysalmamun.wordpress.com/2013/03/27/fat-f...
This is how the main template looks like:
<?php
include('header.html');
include('error.html');
include($view);
include('footer.html');
?>
Answer the question
In order to leave comments, you need to log in
if you take a closer look at MVC, then you will see that the salt of such a pattern is that the controller is the link between the view and the model.
That is, if you are talking about modularity, then it turns out that each module is essentially one controller.
That is, the header is a controller (or group of controllers), the left block of the site is also a controller (or group).
Also, if you use such an entity as a "group of controllers", then this entity must have a trigger that can be pulled and the entire group will be rendered at once and you will end up with a piece of html of this group, etc.
At the level of designing your own CMS, especially a modular one, you already need to move from the banal "we include files from the folder with modules" to something more serious, and this requires both a good understanding of PHP itself and a good understanding of OOP in general: patterns, encapsulation, inheritance , polymorphism, correct use of closures, and so on. Personally, I see two possible ways of development in this direction:
1) From practice to theory, that is, find some popular framework, open it up, see how it works, and figure out / ask why it works this way and not otherwise ;
2) From theory to practice: read about software architecture (at least a Gang of Four book about patterns and some basic things from Fowler), think over the architecture of your CMS and start thinking
The only correct answer to the question "how to organize modularity" does not exist, there are different approaches with their pluses and minuses. The Observer pattern can be considered as the most basic one (in php it is traditionally implemented through SplObserver , and one of its most popular implementations is the Event Dispatcher system from Symfony). You can read about different ways to implement it in code here .
A horizontal menu can be attached to header.html, but then it will not be possible to transfer any data to it, that is, the dynamic menu disappears. Also vertical. If you pass data to it, then you will have to do it every time in each controller and draw it separately in each template, and not include one common html. But that's not the point. How to be?
Connect the general template .
html
body
if menu = true {include menu}
if content = true {include content}
body
/html
-------------------------
controller
menu = true
menu_data() = array
menu_data[list1] = list1; etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question