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
vote
0answers
22 views

How do I translate a programmatically-created custom block?

I am searching from long hours about this problem. I created a block programmatically, in my custom module, with hook_block_info(). I create its fields in hook_block_configure() and save values of ...
0
votes
0answers
28 views

Invalid node context using ContextAwarePluginInterface

I am trying to create a block in Drupal 8 that would help me to show an image using a link given in a certain content type link. I tought it would be useful to use the ContextAwarePluginInterface. I ...
0
votes
0answers
13 views

Add AJAX to view reference field (UPDATE)

i have a custom block with two field viewsreference(field_lg_cb_lista) and field view_mode(field_lg_modo_de_vista ). i want to update the field view_mode to display only the view modes aviable for the ...
-3
votes
0answers
31 views

Print views block in the custom block/ node/ panels (with php filter input) in the Drupal core 8.9.2

In drupal 7, I can print any views's block in node template or custom block (with Text format : php code) by using below code: <?php print views_embed_view('view_name', $display_id = 'block_name'); ...
-3
votes
0answers
20 views

Get one Block from region In front page

I create region 'Top' in backoffice and I replace 'menu', 'block1', 'block2' to that region . In front--page.html.twig I display this region by {{page.Top}}. My question : how to get 'block2' without ...
-3
votes
1answer
56 views

How to show Users facebook page feed on their profile page? [closed]

In my website users can specify their Facebook page id in their profile. Then when we view the users profile page it should show posts from the mentioned page as a block. I have developed this feature ...
1
vote
1answer
31 views

How to use a content type form as a block [duplicate]

I need a page to be half content, half node edit form. How can I do this? I thought I'd put the content type's form display into a block. Sounds easy enough. I've been trying contrib and custom ...
0
votes
1answer
35 views

Block plugin's render array values ending up in $variables['content'] instead of $variables

I've got a bizarre issue where my the render array from my block plugin's build() method doesn't seem to be properly interpreted by the template. I've got the following setup. function my_module_theme(...
-2
votes
0answers
64 views

Allow users to control block visibility for themselves

According to this page, I should be able to give my users the option to show or hide a particular block through their profile settings, as hinted at roughly two-thirds of the way down the page: ...
0
votes
1answer
32 views

Is there a way to enable the Gutenberg editor so I can use it with custom blocks?

I've installed the Gutenberg Editor module and have it working with various content types, however I'd like to also use it to create content for custom blocks (as in structure > block layout > ...
0
votes
0answers
40 views

How to place a plugin block to twig template without any contributed module?

I am using Drupal 8. Have created a custom module, added custom block "LskyTestVideo", created a new page template with its own controller ("LskyOpenTokTestController"). In ...
0
votes
1answer
46 views

Placing a programatically created menu

I'm creating a menu programatically using this code $this->menu = $this->entityTypeManager->getStorage('menu')->create( [ 'id' => $properties['id'], 'label' => $...
0
votes
1answer
16 views

Hide block if no submenu in Twig

I'm creating a node--page.html.twig and I'm using twig_tweak to help render a block for my sidebar to display the sub-menus. Is there a way to hide it if the page doesn't have any submenus? Here's my ...
0
votes
1answer
153 views

How can I prevent one template from displaying cached values?

I have a site with Drupal 8.9 and Twig Tweak. I created 7 view blocks to set up a task list in stores. I want to display a task counter for my current user on my home page. The tasks checks : If the ...
0
votes
1answer
23 views

How to use ajax callback on auto complete field inside a block settings form?

public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $selected = 'value of a field'; $form['node'] = [ '#type' => '...
1
vote
2answers
45 views

Hide/show a custom block [duplicate]

I have created a custom block of id downloadourapp and I would like to show/hide it base on certain statements. I have create my custom module along with .module file where the code should be, ...
0
votes
0answers
16 views

Cache tag problem causing block to disappear

We have a Drupal 8 site with a few thousand pages which are all in a huge hierarchical menu. Many pages display this menu as a navigation sidebar and each page can be customized so the root of this ...
0
votes
1answer
22 views

Fetching and rendering custom-library generated blocks in twig

I am using the following code in my theme to fetch 3 blocks (each containing 4 fields) generated via the custom block library interface i:e all 3 block are of the HomePage-Block type: function ...
-2
votes
1answer
19 views

What is correct way to make custom slider module? slide update problems

I have a custom slider module but the problem is if I make a new slide, it won't appear before drupal cache is cleared. So how can I renew my slides in the module so cache clear isn't needed. My Code:...
0
votes
0answers
35 views

Add a region to the page--front.html.twig

I've created a few new region in my yml regions: header: "Header" jumbotron: "Jumbotron" chiffres: "Chiffres" steps: "Etapes" presentation: "Presentation des formules" ...
0
votes
0answers
20 views

Get reference of Block entity in hook_form_views_exposed_form_alter()

How to get a reference of which block entity this current view exposed form block belongs to in hook_form_views_exposed_form_alter(). $form_state->getFormObject() returns an object of Drupal\...
0
votes
0answers
18 views

Adding section components with populated fields to a Layout Builder enabled node

I'm working on migrating content from fieldable panels panes in D7 to Layout Builder in D8. So far, I've managed to extract the content I need from my D7 database, but I've been unable to add that ...
0
votes
0answers
52 views

How am I meant to display different elements on different pages?

I'm coming to Drupal from more conventional MVC frameworks (Laravel, CakePHP, etc.) In those frameworks, if I want a specific element (say, a form) to appear only on specific pages, then I basically ...
0
votes
0answers
23 views

How to programmatically access custom block's field data? [duplicate]

I need to access the value of the fields field_lb_text and field_lb_glossary, can someone explain me how to go about with this? Thus far I have tried this, function theme_preprocess_block(&$...
0
votes
0answers
15 views

Adding Custom block types to layout builder side menu

I've created a custom bock type but what to either show it under Add GT Blocks or Start my own menu on the layout builder modal. I've placed this in a module so I would like to add it there. Otherwise ...
0
votes
0answers
19 views

How to pass arguments to a custom block in the module [duplicate]

I want to create a block inside my custom module that will render the output from a controller class. I also want to pass an argument to the block based on which list it should work. This is the ...
0
votes
2answers
21 views

How can I have editors select which blocks to be displayed in what order per page?

I have taken on a site that has hard coded page urls in it's page.html.twig for loading specific sidebar blocks based on the url for related content. eg: {% if 'frozen' in url|render|render %} ...
4
votes
2answers
66 views

How can I programmatically copy all blocks of a given theme into the same regions of a new theme?

I would like to switch admin themes from a core theme (seven) to a custom sub-theme so I can add some customization without hacking core. When I install the new sub-theme it creates all the block ...
0
votes
0answers
14 views

How to override views block pager setting programmatically?

I have a class method that I call when I need to get a view render array. I pass the required params as view name, display, etc. public function getView(string $view_name, string $display, array $...
0
votes
0answers
24 views

How do I display a specific field from an entity reference within a custom block template? [duplicate]

I have a custom block type that only has one field: an entity reference to my news content type. I am trying to display two specific fields from the news content type but can't figure it out. This ...
0
votes
0answers
25 views

I accidentally removed the core blocks from content region

I accidentally remove the core/system blocks that normally sit under the content region and now I am not able to access any of the administration page. If I visit my site/user/login, or register, etc,...
0
votes
1answer
25 views

Conditional fields on block add form

I have a custom block type created through the UI and I used the configuration files to export it to a module. My custom block type has two fields and I want users to be able to fill out one or the ...
0
votes
0answers
49 views

How to load block content through ajax callback?

my_module.routing.yml my_module.content: path: '/my_module/path' defaults: _controller: '\Drupal\my_module\Controller\PageController::content' requirements: _permission: 'access content'...
0
votes
1answer
26 views

How do I get block relationships for a content type?

As part of a migration from drupal 7 to drupal 8, I currently have a rather original node display method that I'm trying to reproduce to Drupal 8, but without success. Currently on Drupal 7, this ...
0
votes
1answer
34 views

Programmatically creating a custom block

I followed the steps from https://www.webwash.net/programmatically-create-block-drupal-8/. I have a view already created and I want to render this view in this block. I can't find a good ...
0
votes
0answers
12 views

Custom Block Config - Accepting array of objects

I have built a component following the docs but am wanting to add configure to allow the user to add a series of objects that each contain a 'title' (a text field) and a 'content' (a list of text ...
0
votes
1answer
38 views

How to restrict access to view a block for a certain role? [duplicate]

I have some custom roles such as Premium Membership and I don't want to allow access to this category. The authenticated role is included to Premium Membership or Moderator users because every ...
0
votes
0answers
43 views

Is a block render array built with EntityViewBuilderInterface::view supposed to render full block template or only inner fields?

After rendering custom blocks in templates, I got this js error: Quick Edit could not associate the rendered entity field markup. What I've done so far : In order to render repeatedly custom blocks ...
0
votes
1answer
33 views

Sub-theme adding prefix to all block machine names

On my site, I have created a sub-theme of a sub-theme using this as a guide to set this up https://www.drupal.org/docs/8/theming-drupal-8/creating-a-drupal-8-sub-theme-or-sub-theme-of-sub-theme and it ...
0
votes
0answers
12 views

Contextual filter for month and day [duplicate]

I have created a block that lists all the users () that are years old that same day. The problem is that when I want to add a contextual filter that compares the birth_date field with the current ...
0
votes
1answer
23 views

Drupal 8 Accessing Menu Tree in a Block's JS

How can I pass the menu into a block's javascript? I am trying to build a block for a custom mobile menu (client wants specific logic/animations/etc) and use that in Structure > Block layout > Main ...
1
vote
1answer
47 views

Splitting exposed form filters amongst several blocks

I have a views search page in D8 where I'm I have exposed filters that are shown in blocks. I'm also using search facet blocks. What I want in the sidebar is the exposed filter text search field, ...
0
votes
0answers
10 views

Sort tags in a view by the number of content they are displayed in

I'm trying to make a view that would display only name of tags and the number of content that uses that tag. I have managed to do this following this tutorial: https://www.youtube.com/watch?v=...
0
votes
1answer
19 views

In node add, how to upload file using image from clipboard

How can I paste image from clipboard and save into image_field ?
0
votes
0answers
17 views

How to disable “Tampering rejected … An attempt to update the title of node…”

I write a code to change the node's title after the form is created, but it always says Tampering rejected ... An attempt to update the title of node with ID "42154" was discovered (from "9-2" to "...
0
votes
0answers
39 views

How do I control which tabs a block is displayed in?

Drupal 8.8.1 with commerce 2 installed. Goal is to make better use of the ‘logged-in user’ landing page(My Account) by adding blocks of useful content. Blocks created using the UI as well as coded ...
0
votes
0answers
20 views

How can I generate custom block types for site testing?

Devel generate is great for testing a site and theming without content in place. It doesn't seem to support custom block types. Is there something similar available for these or a patch?
0
votes
0answers
31 views

Custom link in views block

In Drupal 7, I used the Views Panes More Link module to customize the text of the "More" link. I need to do the same thing in Drupal 8. I am using panels but I am open to other soulutions. I have ...
1
vote
0answers
38 views

Render blocks of custom type

Either I'm stupid or I can't search. Sorry if this is a duplicate, but I can't find any answer to my problem. I made a custom block type in admin panel, named it content_under_listing, and then I made ...
0
votes
0answers
16 views

Get data from one editor field and pass that into another editor field

I have no idea if this is even possible, but I figured I'd ask anyway. I'm working with a site that is on Drupal 8, and long story short, we don't have access to extending nor updating much so any ...

1
2 3 4 5
55