Skip to main content

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
1 answer
83 views

How do I display a block after changing its ID?

I have a custom block. I want to change its ID, but after I changed it from main_menu_block to header_block, the block is not displayed anymore. I tried to: Remove the block with the old ID Change ...
Mykola's user avatar
  • 19
1 vote
1 answer
51 views

Cache two sets of nodes [closed]

I have a website where I have some blocks that have one content on all nodes, but different content on nodes with certain NID. Right now, I have condition in block template based on node ID and blocks ...
Klemen's user avatar
  • 11
0 votes
1 answer
72 views

Block Configuration Form Returning Unexpected Value

I'm trying to build a block configuration form. Here's my blockForm code: public function blockForm($form, FormStateInterface $form_state) { $form['resolve_ip_addresses'] = [ '#type' => ...
Scott Hollenbeck's user avatar
-1 votes
2 answers
281 views

Passing variables to template rendering

I want to render "file-video.html.twig" template. This is the documentation: https://api.drupal.org/api/drupal/core%21modules%21file%21templates%21file-video.html.twig/9.3.x This is my code: ...
drupaltest's user avatar
0 votes
0 answers
118 views

Is there a block visibility condition for entity types?

By default, Drupal core's node module provides a "Content type" visibility condition for node content types. Is there a similar "Entity type" visibility condition to restrict block ...
Patrick Kenny's user avatar
0 votes
0 answers
23 views

Twig template for field component of specific form [duplicate]

I'm using template hints to attempt to theme a specific part of a single form. I have a custom template for a views block (block--views-exposed-filter-block--search-custom-page-1.html.twig), but is it ...
Sam's user avatar
  • 623
0 votes
1 answer
192 views

How to translate breadcrumbs block via drupal_block() in twig?

I am trying to translate the breadcrumbs block in Drupal 9.3 via Twig Tweak I am loading the block in a twig like so: {{ drupal_block('system_breadcrumb_block') }} If I leave it like this, it only ...
Ivan Ginovski's user avatar
0 votes
0 answers
31 views

For specific block use unique template file located in custom module's templates folder [duplicate]

Within my custom module 'footermenu' I would like to specify a template file for a specific menu block. I also want to locate the template file within the /templates folder of my 'footermenu' module. ...
websoft's user avatar
0 votes
1 answer
354 views

When I add an emoji in full HTML with CKeditor 5, I get a PHP error

I created a custom block with Full HTML text format and CKeditor 5. When I add an emoji, I have a PHP error in my Drupal 9 logs : Drupal\Core\Entity\EntityStorageException : SQLSTATE[22007]: Invalid ...
Mathieu's user avatar
1 vote
2 answers
168 views

submitForm not being called when put inside a Custom Block

I have been trying to find a fix for this but I haven't been able to. I have tried to put a form inside a custom block to render the form as a component. When the form is submitted it renders the ...
techenzie's user avatar
0 votes
1 answer
28 views

How to differentiate the state when a contextual filter is applied?

Hello to all the Drupal community. I've recently faced a challenge to visually modify some parts of my view's template for the state when its contextual filter is applied. Some details are as follows: ...
Themetis's user avatar
0 votes
2 answers
84 views

Saving block translation with large amount of text causes PDOException: Data too long for column 'translation'

I have a Drupal 7 project where I am using a Panel to patch together some Drupal blocks. These blocks have to be translated and I just added some data to the current French translation and apparently ...
David Pugh's user avatar
-3 votes
1 answer
238 views

How to display a block on the home page when the user is authenticated or anonymous?

I created two custom blocks. I want to display its two blocks only when the home page view is empty. I want the custom block with id 11 to be displayed for anonymous users. I want the custom block ...
francky's user avatar
0 votes
1 answer
428 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 ...
ACanadianCoder's user avatar
0 votes
1 answer
525 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-...
Prizem's user avatar
  • 23
0 votes
0 answers
60 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 ...
hip's user avatar
  • 15
0 votes
0 answers
35 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 ...
Charles's user avatar
  • 225
0 votes
0 answers
199 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 (...
UnqtiousDude's user avatar
0 votes
0 answers
94 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 ...
juankvillegas's user avatar
0 votes
0 answers
431 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; ...
Alimba's user avatar
  • 117
0 votes
1 answer
593 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('...
Asad ullah's user avatar
0 votes
1 answer
773 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'...
user94155's user avatar
1 vote
0 answers
352 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. ...
Ryan Kavalsky's user avatar
0 votes
1 answer
265 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? ...
Seth M's user avatar
  • 31
0 votes
1 answer
2k 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 ...
Yurii Kovalchuk's user avatar
1 vote
0 answers
122 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() ...
cjobes's user avatar
  • 11
0 votes
1 answer
277 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 ...
liquidcms's user avatar
  • 1,278
0 votes
1 answer
135 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 ...
Steve's user avatar
  • 361
-1 votes
2 answers
46 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 ...
Arcticooling's user avatar
0 votes
1 answer
99 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: ...
erutan's user avatar
  • 1
0 votes
1 answer
416 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 ...
Sarah C's user avatar
  • 490
0 votes
2 answers
183 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 ...
Steve's user avatar
  • 361
0 votes
1 answer
136 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 '...
Jorn Reed's user avatar
0 votes
1 answer
437 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 ...
zoulou66's user avatar
-2 votes
3 answers
483 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() { ...
Akki's user avatar
  • 381
0 votes
2 answers
930 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 ...
mauzilla's user avatar
  • 173
-1 votes
1 answer
29 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 ...
wilburunion's user avatar
0 votes
2 answers
573 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 $...
Andreas's user avatar
  • 412
0 votes
1 answer
46 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 ...
Mat's user avatar
  • 5
-1 votes
1 answer
52 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\...
rukya's user avatar
  • 221
0 votes
0 answers
165 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\...
rukya's user avatar
  • 221
1 vote
1 answer
314 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 ...
uotonyh's user avatar
  • 133
0 votes
1 answer
352 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 ...
artfulrobot's user avatar
  • 4,019
0 votes
2 answers
561 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 ...
gkaruppusamy's user avatar
2 votes
1 answer
646 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 ...
Robin's user avatar
  • 161
0 votes
2 answers
475 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 ...
liquidcms's user avatar
  • 1,278
0 votes
1 answer
211 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 ...
Greg Sims's user avatar
  • 573
3 votes
0 answers
414 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 ...
ProjectAlice's user avatar
0 votes
1 answer
191 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 ...
Dorian Winterfeld's user avatar
0 votes
0 answers
424 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 ...
wolves11's user avatar

1
2
3 4 5
58