By sabzh - on the basis of a samopnaya system, it is difficult to say exactly what you need to do. See how it is implemented in Yii2 . For example, you have products in categories-subcategories. It is necessary in the submission to display the template based on an array of links-names, these links and names need to be determined independently, i.e. This is actually a manual control. Those. for example, you have a Nokia 7310, you put the name of the last element of the array without specifying a link, find the parent subcategory through the query in the database and category (for example, Nokia subcategory, category Telephones) and you should add all this to the array, which you need to pass to which, through some method, gives a pattern based on the data obtained. All this should happen in the action or display, and for each type of page you need to define your own rules. For example, at the level of a subcategory without a link, the name of the subcategory will already be there, there will be no specific phone, etc.
But ... Copy your comment:
Perhaps not entirely correct on my part, because I am not a PHP guru and have not been working with PHP for more than a year, but see how it is done better in cool framework projects (Laravel5, Yii2, Symfony3), learn how to do it right (of course, it will not work right away, but still). Anyway, in real projects, with a 95% probability you will use some kind of framework. For 5 years I have not used the samopinnye systems. You can deal with PHP on the basis of the framework. If it is difficult - pull up the OOP, then again for the framework)
Of these 3 frameworks, symfony will be difficult for elementary education, but I advise you to devote some time to it. There you can see a slightly different implementation of the usual things.
PS I found this answer in similar ones. It may also be useful.