Answer the question
In order to leave comments, you need to log in
How to correctly display a page with several blocks of materials by different parameters in Yii2?
It is necessary to display several blocks of materials (articles) on the page. In each of the blocks, materials are selected according to their own criteria. It is logical to write in action $blockNodes1 = $query1->all(); $blockNodes2 = $query2->all(); .... i.e. write your own ActiveQuery for each block (selection) and pass the corresponding number of blocks of materials (Active Record arrays) to rendering - but with this approach, the concept of "thin controller" becomes very conditional (because $queryN comes with join s on several links) . Another option is to write portlets for identical blocks. So what's your option? How right?
Answer the question
In order to leave comments, you need to log in
Are there any dependencies between the blocks?
I would put a method in the model that would return an array with the required number of blocks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question