Score:0

Show a block only in in the front page and not in every pager page

cn flag

I configured a block to be shown only on the front page, but the front page is actually a view of the last published nodes, with a pager, and the block is shown on each of its pages.

Is there any convenient way to show the block only once? I know it is possible to write a hook that checks if the page parameter is set and hide the block in that case.

What hook should I use to achieve this?

Score:0
de flag

You could create a custom @Condition plugin, where the result is true when on the first page, and false whenever a URL parameter exists for page. Then you could set this context as the block context.

I wrote a tutorial on creating custom @Condition plugins here: https://www.jaypan.com/tutorial/custom-drupal-block-visibility-plugins-and-condition-plugin-api

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.