- Issue created by @RustedBucket
- πΊπΈUnited States RustedBucket
I figured out how to do this by overriding the custom block template. This can be closed.
Basically what I'm looking to do is load a block that renders header and footer content and then displays the Ajax results between the two.
When I add the ajax_placeholder it's always attached to the end of the render array so the block is rendered and displayed, but the 'loading' message is displayed underneath the already rendered content.
$build['awesome'] = [
'#type' => 'ajax_placeholder',
'#callback' => ['my_custom_service:customLazyBuilder', []],
];
$content = '<div id="custom-block" class="block-items">';
$content .= '<div class="custom-links">';
$content .= '<p><a href="https://google.com">Go to Google</a></p>';
$content .= '<p><a href="https://microsoft.com">Go to Microsoft</a></p>';
$content .= '</div>';
$content .= '</div>';
What I'd like to do is something similar to how BigPipe works:
$placeholder = 'my_custom_placeholder'. crc32('lazy custom block');
$build['#attached']['placeholders'][$placeholder] = [
'#type' => 'ajax_placeholder',
'#callback' => ['my_custom_service:customLazyBuilder', []],
];
$content = '<div id="custom-block" class="block-items">';
$content .= $placeholder;
$content .= '<div class="custom-links">';
$content .= '<p><a href="https://google.com">Go to Google</a></p>';
$content .= '<p><a href="https://microsoft.com">Go to Microsoft</a></p>';
$content .= '</div>';
$content .= '</div>';
Essentially I want the static block to load and display the loading message and Ajax data in a custom location. Is it possible to do this now?
Active
1.0
Code
I figured out how to do this by overriding the custom block template. This can be closed.