Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
0 votes
0 answers
12 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. ...
user avatar
  • 47
0 votes
1 answer
22 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 ...
user avatar
1 vote
0 answers
25 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() ...
user avatar
  • 11
-1 votes
0 answers
22 views

Filter block by tag

I consider to filter blocks by taxonomy tag. Making a block to appear only in webpages which include a certain taxonomy tag. From the last time I checked, one can filter blocks by content type but not ...
user avatar
  • 1
0 votes
1 answer
30 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 ...
user avatar
  • 897
0 votes
1 answer
42 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 ...
user avatar
  • 349
0 votes
2 answers
34 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 ...
user avatar
  • 15
0 votes
1 answer
44 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 ...
user avatar
  • 15
0 votes
1 answer
27 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: ...
user avatar
  • 1
0 votes
1 answer
32 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 ...
user avatar
  • 440
0 votes
2 answers
85 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 ...
user avatar
  • 349
0 votes
1 answer
27 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 '...
user avatar
0 votes
1 answer
36 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 ...
user avatar
-2 votes
3 answers
119 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() { ...
user avatar
  • 351
0 votes
0 answers
22 views

How can I display a field from the current node?

How can I create a view block that displays a field from the current node? It looks like there are contributed modules that provide this functionality, but it seems like it should be possible to ...
user avatar
0 votes
2 answers
47 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 ...
user avatar
  • 163
0 votes
1 answer
17 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 ...
user avatar
0 votes
2 answers
37 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 $...
user avatar
  • 271
0 votes
1 answer
20 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 ...
user avatar
  • 5
-1 votes
1 answer
26 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\...
user avatar
  • 173
0 votes
0 answers
35 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\...
user avatar
  • 173
1 vote
1 answer
22 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 ...
user avatar
  • 133
0 votes
1 answer
50 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 ...
user avatar
  • 3,909
0 votes
2 answers
73 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 ...
user avatar
2 votes
1 answer
78 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 ...
user avatar
  • 133
0 votes
2 answers
57 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 ...
user avatar
  • 897
0 votes
0 answers
16 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 ...
user avatar
  • 897
0 votes
1 answer
59 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 ...
user avatar
  • 513
1 vote
0 answers
40 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 ...
user avatar
0 votes
1 answer
66 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 ...
user avatar
0 votes
0 answers
64 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 ...
user avatar
0 votes
0 answers
122 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 ...
user avatar
  • 894
2 votes
2 answers
42 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 ...
user avatar
  • 121
0 votes
0 answers
10 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 (...
user avatar
  • 129
0 votes
0 answers
91 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 ...
user avatar
-3 votes
1 answer
74 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 ...
user avatar
  • 1
0 votes
1 answer
50 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 ...
user avatar
  • 72
2 votes
1 answer
68 views

Add a custom variable to an existing block

Is there a way to alter the render array of an existing block? I want to do it for a commerce block (cart block) but the question remains for any core or contrib module block. When a block uses a ...
user avatar
  • 331
1 vote
2 answers
203 views

How to add class to multiple view-blocks using twig?

I have four blocks to a view. I want to add class 'fancy-body' to all four blocks. How can I add that. view_id : categories display_id's of blocks : block_1, block_2, block_3, block_4 I know, I can ...
user avatar
0 votes
0 answers
23 views

How do I dynamically add filters?

I have a view_block with the following filters, I want to change the product tag, Release tag, Document type values dynamically based on url. if the url is, example.com/mars/21.43.00/ProductGuide, ...
user avatar
0 votes
0 answers
24 views

How to add contextual filter?

I am working with books in drupal 8. I want to display a specific page("table of contenets") on the sidebar whenever any page of that book is accessed. "table of contents" is a ...
user avatar
0 votes
1 answer
93 views

Hide and unhide custom block programatically drupal 9

Hello I have created a module to display a block. I would like to set the block visibity to visible and hidden in the homepage based on a condition. like this: edit: //fetch status from database then ...
user avatar
0 votes
1 answer
71 views

Custom block plugin: Give access to edit form

I am creating a custom block plugin with custom configuration options (blockForm()). I would like to allow content editors to edit the configuration of this block, without giving them "administer ...
user avatar
  • 3,482
1 vote
0 answers
31 views

How do I get the selected image style from a referenced media field?

I created a custom block with an entity reference to a media field (field_background_image). In the display settings I have chosen 'Thumbnail' as format and selected a custom image style 'background'. ...
user avatar
  • 41
0 votes
0 answers
35 views

How can I make certain fields of my block implementation translatable?

I've created a simple module, which extends BlockBase to provide a custom block. This block class has a few fields (e.g., "Header"), which I would like to be translatable. How can I ...
user avatar
0 votes
1 answer
54 views

Extending block, a block with a paragraph field, and 3 paragraph fields... how to loop through the paragraphs from the block extension

This is what I have: I have three twig files: block--paragraph-images.html.twig (which extends block.html.twig) field--field-paragraph-image-block.html.twig (the paragraph field which is located in ...
user avatar
2 votes
1 answer
98 views

Block Settings inside Form

Please I need help with my code. I have a form and a block created programmatically. The block embeds the form to show it on the frontend. The block also has some settings (form preffix text). I want ...
user avatar
1 vote
3 answers
111 views

Attempting to return region in theme suggestions for the book module book tree block

Editing question based on information from @NoSssweat The book module uses the same hook for the book tree block and the rendered index view in the book page. I have used the below code to return file ...
user avatar
  • 121
1 vote
1 answer
176 views

How to alter Layout Builder block visiblity?

Is there a hook to alter block access for blocks placed using Layout Builder? I see there is hook_block_access; but sadly this is not triggered when the block is placed using Layout Builder. There is ...
user avatar
  • 897
0 votes
1 answer
26 views

How to change the condition to AND in accessing content by role in a view-block?

I have a view-block 'Expo', I want to display this block only if current user has two specific user roles i.e., 'Actor' and 'Singer'. When I checked the both 'Actor' and 'Singer' , The block is ...
user avatar

1
2 3 4 5
57