I have a block that I want to show on the front page, but not on every paged page (i.e., don't show it on /front-page?page=1).
How can I achieve this?
I have a block that I want to show on the front page, but not on every paged page (i.e., don't show it on /front-page?page=1).
How can I achieve this?
Install and enable request_data_conditions module
Then on the configuration of your block add following settings
<front>
page
as must not be set
page
as must equal
0 Have you configured the block as shown in screen shot?
If this block is generated using code, also have a look at code also.
In hook_preprocess_page() add the following code.
if(!isset($_GET['page'])) $block_entity = Drupal\block_content\Entity\BlockContent::load(BLOCK_ID);// BLOCK_ID $block_view = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block_entity, 'DISPLAY_VIEW_NAME'); if ($block_view) { $variables['page']['my_block'] = $block_view; } }
In your Twig template, print the block with the following code.
{% if page.my_block %} {{ page.my_block }} {% endif %}
Refference: Render a custom block programmatically