Panels control panes render sequence

Panels standard renderer has very flexible undocumented feature of controlling the sequence of panels being rendered.

By default you have possibility to use 'render first' and 'render last' in your content type definition so you already can control what pane should be rendered for example last. Undocumented part is more interesting that is hook_panels_panes_prepared_alter() that runs after all panes were set up. So you can alter the array of panes in which way you can control sequence of panes being rendered. This feature is super handy when you have dependent panes.

Example can be if you have several panes with list of news articles. Lets say one block displays 3 items and another block displays other 5. But the problem is that editors can place blocks independently and you do not know whether you have two blocks on the page or only one. But you know that block that have 3 items should be rendered first and then block of 5 so first block has more recent news articles. Using properties 'render first' and 'render last' you can do the trick. When you render 3 items block you can save some static variable so when you render 5 items block you can check that variable and if previous block set it to TRUE you need to shift your list to 3 items so you won't duplicate news articles in both lists.

Meanwhile if you have multiple combinations of similar blocks you can use hook_panels_panes_prepared_alter() and control which block renders first and then you will still have very nice lists of articles.

I would like to thank Andrii Tiupa for pointing me to this brilliant feature.