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
14 views

get a paricular menu url and title in programtically created block

I have a menu and added few menu in under it. Let say sub-menu page-1 Link - https://example.com/pag-1 - meni_id: 1 page-2 Link - https://example.com/pag-2 - meni_id: 2 page-3 Link - https://example....
0 votes
0 answers
6 views

Why might a panel pane print a block as class="panel-pane pane-block..." vs class="block block--views..."?

I apologize if the wording for this question title does little to explain my problem. I'm so deep into not understanding an issue I'm having trouble describing it. To preface, I'm quite a noob with ...
1 vote
1 answer
40 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 ...
  • 11
0 votes
1 answer
52 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' => ...
0 votes
0 answers
20 views

Access field from current page in block or view

I have a custom content type. (d9) I need to access some fields from the current page in a sidebar area. Essentially I need to make a "get more info about "field from current page" here ...
  • 1,221
-1 votes
2 answers
50 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: ...
0 votes
0 answers
58 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 ...
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 ...
  • 545
0 votes
0 answers
34 views

Changing from CKEditor 4 to CKeditor 5 Textformat got lost

Since I changed from 9.4.0 to 9.5.0 I tried to use the CKeditor 5 But when I wanted to modify the Text formats and editor full HTML, it didn't work. so I delete the full format HTML. But when I wanted ...
  • 13
0 votes
0 answers
23 views

How to access block contents in run within hook_form_alter? [duplicate]

I am using Drupal 9 and I need to get the block content within hook_form_alter implementation, I tried these lines: $bid = 'consumerorganizationselection'; $block = \Drupal::entityTypeManager()->...
0 votes
1 answer
92 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 ...
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. ...
0 votes
1 answer
157 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 ...
0 votes
1 answer
72 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 ...
0 votes
1 answer
24 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: ...
0 votes
2 answers
47 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 ...
0 votes
0 answers
20 views

Get all taxonomy terms from one vocabulary used by articles with a term in another vocabulary?

15+ years Joomla user but Drupal newbie here. Taxonomies are causing me a little bit of a headache. For my articles I have set up 2 taxonomy vocabularies: Category and Tags. Each article can (must) ...
0 votes
0 answers
20 views

How would I go about making a view showing contact information of a user refrenced in the account field?

How would I go about making a view showing the contact information of a user referenced in the account field? I am making a site which will be offering several services where customers will get an ...
-3 votes
1 answer
58 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 ...
0 votes
1 answer
116 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
201 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-...
  • 23
0 votes
0 answers
53 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
19 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
89 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
61 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
87 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 ...
0 votes
0 answers
185 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
314 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
377 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
101 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
147 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
18 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
731 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
88 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
77 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 ...
  • 1,008
0 votes
1 answer
69 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
40 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
64 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
47 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
208 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 ...
  • 470
0 votes
2 answers
127 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
65 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
136 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
236 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() { ...
  • 371
0 votes
2 answers
457 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
-1 votes
1 answer
24 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
219 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 $...
  • 312
0 votes
1 answer
26 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
38 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\...
  • 221
0 votes
0 answers
93 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\...
  • 221

1
2 3 4 5
58