I am using the following code in my theme to fetch 3 blocks (each containing 4 fields) generated via the custom block library interface i:e all 3 block are of the HomePage-Block type:
function legislation_research_theme_preprocess_page(&$variables, $hook) {
for($i = 1; $i <= 3; $i++) {
$block_entity = Drupal\block_content\Entity\BlockContent::load($i);// BLOCK_ID
$block_view[$i] = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block_entity);
}
if ($block_view) {
$variables['page']['my_block'] = $block_view;
}
}
In my page--front.html.twig, my blocks output via:
{{ page.my_block }}
However, the output is of the individual fields from each of the blocks rather than 3 divs containing 4 fields of content from each block. That's making it impossible to to style:
Can anyone advice how I might be able to output each block but contained in individual parent divs?