Questions tagged [blocks]

In Drupal, a self-contained collection of content and functionality that is displayed in theme regions is called block.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
53 views

How to layout blocks?

How to layout blocks? How to split a block into two or more sub-regions (sub-layouts) responsively, without involving any CSS coding by the end-user? We would get, for example: |-| |-| Or |-| |-| |-...
0 votes
1 answer
33 views

How to custom output a media paragraph from within a custom block?

I have a two-column custom block type that has two fields field_content_left and field_content_right which are entity reference revisions to allow the use of my other paragraph types. One of my ...
0 votes
1 answer
58 views

Custom module block doesn't work

I have a custom module where its only purpose is going to be serving up a block. I basically used these instructions: https://www.drupal.org/docs/creating-custom-modules/creating-custom-blocks/create-...
  • 1
0 votes
0 answers
41 views

Conditional filter for visitor role

I'm throwing a big number of views showing a list of 'events' (nodes) happening today, tomorrow and after tomorrow. I'd like registered users with role 'editor' could see all events from today (not ...
  • 17
0 votes
0 answers
16 views

How can I make a theme region expand height to fit content of several blocks, pushing all following region content down?

After a long hiatus from Drupal work, I now need to meet a request to modify a Drupal 7 site. In the existing theme I need one more full-width theme region than what's available. (At one point I had ...
  • 225
0 votes
0 answers
50 views

Anonymous users suddenly unable to see block on page

A client has reported an issue where anonymous user/visitors no longer can see a field block created in layout builder. This has been happening about once a month and it only affects a single page (...
0 votes
0 answers
52 views

Block cache for anonymous users depending on previous behavior

I have a content type named "Campaign". Each Campaign has a totally different look and feel in the website. Once a visitor wants to join a campaign, the user is redirected to the normal ...
0 votes
0 answers
51 views

Replace a Custom Block Via Ajax

I have a block on my page that shows summary information for a content entity. In particular, it shows a boolean value on if the user has watched a video or not. I have already implemented that the ...
  • 323
0 votes
1 answer
49 views

How to move the attachment of a view, in a region?

The question is simple, I have a Drupal 9 website with the Geolocation Field module. I use the Olivero theme. In this theme, there is a "Hero (full width)" region. I want to display a View ...
user avatar
0 votes
1 answer
54 views

RequestContext::fromRequest() error when run $block->save() in a Drupal module [closed]

I just need a way to enable a block when page path contains a certain string. I've tried to achieve this goal via the following code inside of my custom module: use Symfony\Component\HttpFoundation\...
  • 193
0 votes
0 answers
54 views

Custom block translations

I have build custom sections and blocks to provide for the layout builder. Here is an example of my block code: <?php namespace Drupal\hs_blocks\Plugin\Block; use Drupal\Core\Block\BlockBase; ...
  • 105
0 votes
1 answer
61 views

How to render a custom block with variables from another custom block twig template

I have a custom block with some values I can access in the template of that block, for example the product_type variable. In the same template file I'm adding another view block with {{ drupal_block('...
0 votes
1 answer
106 views

Access preprocess variable globally

I am trying to get the Custom Block type fields using a preprocess hook. I can successfully use the following code. function theme_preprocess_block(&$variables) { $content = $variables['elements'...
1 vote
0 answers
50 views

My custom block doesn't show up in the block library

I'm writing a custom Drupal 8 module that creates a block. On my local sites, I can enable this module and add this block to whatever region I'd like, and the block shows the correct contents. ...
0 votes
1 answer
73 views

How can I hide a block from regions?

I successfully place block with twig_teak module programmatically in my twig file. Unfortunately in order for this to work, it needs a region in the UI. How should I hide it from its original region? ...
  • 31
0 votes
0 answers
17 views

Fluid UI container is injected in code without location choice for the developer

Problem I have installed the FluidUI module on my D9 website. It works fine, can use all the settings to change look and feel of the website to accommodate all people with accessibility issues. ...
  • 47
0 votes
1 answer
186 views

There were errors validating the config synchronization

Locally I deleted custom block "CTA" from custom blocks and block types. Then I exported configs and created merge request. After merge is accepted, the pipeline runs commands on the dev ...
1 vote
0 answers
37 views

Sending data to custom block [closed]

I created a module that has several pages of administration. One of these pages is a block creation page. When the block is created the name of the block is kept in the database. The block build() ...
  • 11
0 votes
1 answer
52 views

How to pass Block ID to a view?

I have a Custom Block type called HomeBlocks. This bundle has a paragraphs field which allows multiple paragraphs. I then place (using Layout Builder) an instance of this block type on my home page (a ...
  • 937
0 votes
1 answer
45 views

How can I programmatically add or remove a new request_path to block visibility?

It seems like I could utilize the getVisibilityConditions method on the block, which returns a ConditionPluginCollection object with a setInstanceConfiguration method, which is apparently easy enough ...
  • 349
0 votes
2 answers
36 views

How to display a content-management-system-agnostic contact form I have developed, just without iframe?

I have developed a simple, content-management-system-agnostic[1] PHP-HTML-JavaScript-CSS contact form which I normally embed by iframe but I no longer want to use iframe due to the form appearing ...
  • 15
0 votes
1 answer
52 views

How to put a phone number in one place and call it from various other places? [closed]

Let's say I want to store my phone number in some "Drupal variable" and then call it anytime I need it, in, say, a node or a block. The purpose is not the repeat the phone number and change ...
  • 15
0 votes
1 answer
34 views

Any idea why exposed sort filters won't show up when configured correctly in D9.3 (works on simpletest.me instance)?

D9.3.12 I have a block view with sort criteria configured, but no exposed sort criteria show up in the preview or on the site when placed - "Exposed form in block: No" and "Use Ajax: ...
  • 1
0 votes
1 answer
97 views

Add a new contextual link to custom block type to edit layout

I have a custom block type using Layout Builder. How do I add an Edit Layout item in the contextual link menu? The link should go to /block/{nid}/layout; after saving, the layout returns to where you ...
  • 440
0 votes
2 answers
102 views

Which cache should I invalidate in a block plugin that builds render arrays for one or more views?

The real issue is that the plugin will sometimes be returning render arrays that are discrete block displays from the same view, possibly also with different arguments. What I'm discovering is that in ...
  • 349
0 votes
1 answer
40 views

Main page content block doesn't move

I'm currently building a Drupal 9 site. I've built some custom blocks, which I display on a specific 'basic page'. I want the 'Main Page Content' block to be above my custom blocks. So I moved the '...
0 votes
1 answer
52 views

How to display the current year in the template of a block?

I'm trying to rewrite the "Powered by Drupal" block. I want to display the current year in my code but cale does not work. The website displays a blank page with the message "The ...
-2 votes
3 answers
147 views

How do I show a block with a unique QR for each node? [closed]

There is requirement where I need to Place a Block on node where each block will be having the Unique QR code. I created an hard-coded QR code block with the following code. public function build() { ...
  • 351
0 votes
2 answers
151 views

Render block in a view twig template

I need to render the output of a block within a view / node template (node--news--full.html.twig). Using {{ page.blockName }} does not return anything as {{ page }} within a node view simply returns a ...
  • 173
0 votes
1 answer
20 views

Default product URL for a pager

Does anyone know how to get around the view error about the default product that doesn't have a URL? The Commerce module has a default product and the view pager works without a More link, but it ...
0 votes
2 answers
76 views

How do I get the type of a "Custom block" entity?

I created two custom block types. How do I retrieve the type of custom block in hook_theme_suggestions_block_alter()? function mytheme_theme_suggestions_block_alter(array &$suggestions, array $...
  • 280
0 votes
1 answer
22 views

How do I display a view block next to the branding block in the header?

I have created a view (Slideshow) containing a Flex Slider slideshow I want to display in the free header region right of and next to the branding block. I'm using the Bartik theme; I was disappointed ...
  • 5
-1 votes
1 answer
31 views

How can I pass more variables/trigger preprocess to plugin block?

The block opigno_documents_last_group_block is located in opigno_learning_path/src/Plugin/Block/DocumentsLastGroupBlock.php, which looks like this: <?php namespace Drupal\opigno_learning_path\...
  • 201
0 votes
0 answers
55 views

How can I extend custom class extending BlockBase in contrib module?

The block opigno_documents_last_group_block is located in opigno_learning_path/src/Plugin/Block/DocumentsLastGroupBlock.php, which looks like this: <?php namespace Drupal\opigno_learning_path\...
  • 201
1 vote
1 answer
41 views

How to place facet blocks

I got Search API and Facets configured, built a View Source, and connected the Facet to that source. Now I'm stuck with how to present that widget! With D7 Facets, it configured Blocks that I could ...
  • 133
0 votes
1 answer
81 views

Block doesn't show up in the entity reference UI

I have an Entity Reference field, whose "type of item to reference" is block. I have a View that creates a block called staff list but when I edit content that uses that field, I can't get ...
  • 3,949
0 votes
2 answers
131 views

How to extend core block class SystemBrandingBlock

Please advice how we can extend the core block class Drupal\system\Plugin\Block\SystemBrandingBlock to add custom method. In my case, I want to include function buildToArray() to get the block data in ...
2 votes
1 answer
130 views

Display custom module block in page content

I have created a custom module providing a block. The block is available in the block library under "Block Layout" (/admin/structure/block). On the other hand, I have a custom content type ...
  • 133
0 votes
2 answers
102 views

How to cache View block by content language?

I have a very simple (block) view to list a node's title. This view has an id from url contextual filter and a single filter to filter on Content language set for the page (by URL prefix). This block ...
  • 937
0 votes
0 answers
23 views

Does Views block caching include language in cid?

I think this is likely a core bug (in which case I know it is not meant for Drupal Answers) but thought I would check here first to see if possibly I have just missed something in configuration? I ...
  • 937
0 votes
1 answer
72 views

Custom Module Rename

We have three custom pieces of code for our Drupal website: module, theme and a non-drupal php library. The names of these components have become awkward over time. I would like to rename our custom ...
  • 533
2 votes
0 answers
133 views

How to refresh/rebuild block without reloading the page?

I have a custom block which displays the number of events added to favorites(Flag module). I am using the TWIG template to display those results. I want to refresh the block contents right after the ...
0 votes
1 answer
85 views

Why is the Aggregator module not creating a block

I am using the Aggregator module that is part of Drupal 9 core. I am following the docs on drupal.org: https://www.drupal.org/docs/8/core/modules/aggregator/overview After I create a feed and update ...
0 votes
0 answers
159 views

Better exposed filter for block view doesn't appear

I created a new content type and a display page to show a listing of all my new content type pages. I'm trying to create a better exposed filter block on my page for the sidebar, but when I try to add ...
0 votes
0 answers
143 views

--2 is appended to the block ID

I have a strange problem. After upgrading a website from D8 to D9, some of my block IDs are changed. Some of them now have --2 behind the ID. This is messing up my styling and scripts. And I'm ...
  • 936
2 votes
2 answers
44 views

Get the time a custom block was last edited

I have seen lots of answers for getting when a node was last edited, but I can't seem to apply any of these methods to blocks. Basically, I have a block that I only want to display if it has been ...
  • 121
0 votes
0 answers
14 views

How to display group operations block not in a dropbottom menu either "normal" links list/HOOK_block_build_group_operations_alter does not fire

currently the links of the "group operations block" of group module are displayed in a dropbutton menu. I want them to get displayed in a "normal" link list. I found an issue (...
  • 129
1 vote
0 answers
127 views

How do I prevent a block from being loaded via Big Pipe

I have a view block, nothing crazy, just a couple fields. I want to present it as a carousel. Everything worked fine, until suddenly Drupal decided to start loading the block asynchronously with Big ...
-3 votes
1 answer
90 views

How to track recently viewed nodes using JavaScript on a completely cached website?

I want to make a block of recently viewed nodes on a website which is completely cached using Boost module (it saves a static HTML page for every request on the website). I don't want to disable Boost ...
  • 1
0 votes
1 answer
73 views

Webform block shows for anonymous user but not authenticated

I am using the webforms module (6.1.1) on a Drupal 8 site for a form that shows up in a block on my front page. If I am not logged in (go Incognito or InPrivate mode) the form displays and works. If I ...
  • 82

1
2 3 4 5
57