In the online store there is a history of orders of the User, and there are two types of Users: Eureka and Physics. And the trick is that for Yurikov more information is shown in the history of orders, not for Physicists. And because of this, in a template that displays a history of orders all kinds of ifs appear, such as

{% if user.isB2b() %} <div>bla-bla-bla</div> {% endif %} 

So besides this, our Controller is increasing, which should receive additional. data from services for Yurikov.

Is there any way to make it more beautiful, transparent? Maybe there are some techniques? I don’t even have ideas ...

  • Different templates for businesses and individuals? - Visman
  • @Visman Well, you can do it, but then there will be a copy-paste, which is even worse - AmsTaFFix
  • At first, I thought it was about physicists and lawyers))) - Razzwan

1 answer 1

Take out different information in a separate block. There may be several blocks, but in one file. Fortunately, twig inheritance allows you to turn any sophistication. Kopipasta will be zero. It will look elegant;) - if will be only one.

  • Yes, but given that these if'ami pattern is permeated completely, we will very much complicate the life of the layout makers and ourselves ... Of course, we thought about the blocks - AmsTaFFix
  • I see only 2 options: 1. Put in a separate file in blocks. 2. Make a separate view for each type of user. Choose what suits you best. - Razzwan