I make a trial site on the mvc system. There are models, controller, router. How to make bread crumbs? Help me please. How to write them and where to shove?

Update

The problem is this - you need to bring bread crumbs. I try to write these crumbs ... but I still don’t understand what file to put them in and therefore how to make these crumbs. It seems to me that I need to do something in the router)) I want to, when I click on a category and (or) on a product, I have bread crumbs, a "covered path."

Closed due to the fact that the essence of the question is incomprehensible by the participants cheops , ermak0ff , HamSter , aleksandr barakin , αλεχολυτ 11 Nov '16 at 9:03 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Do you do in the framework? Yii, symfony there? If so, look in the documentation for the breadcrumbs framework (bread crumbs in English) - A1essandro
  • one
    I understand that "there is no framework." Those. Have you made a MVC structure from scratch? Better use existing frameworks, they will VERY make life easier for you (unless, of course, this is not a combat project that will need to be rewritten first). There and bread crumbs, routing customizable, and everything is beautiful (if you choose a good framework). - A1essandro
  • I'm new to php..and I need to do everything myself)) - Egor
  • one
    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) - A1essandro

2 answers 2

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.

    Perhaps you will find the easiest way as on OpenCart

    $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); 

    in a search.

    The fact is that this method is one of the most accurate, because you can directly correct the data. And the proportion of error is unlikely.