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
0answers
19 views

Replace Block on click of form element

I have a block which contains a form (I used the build() method) . One of the form elements has a suffix as follows: $form['test'] = array( '#type' => 'number', '#placeholder' => t(...
0
votes
0answers
39 views

Why does my custom block disappear after page reload?

I have created a custom block with a custom module (Example: https://www.webwash.net/programmatically-create-block-drupal-8/). The goal is to display some external content, which is working. The only ...
-2
votes
0answers
33 views

Ajax request to API in custom block each minute

I want to display a counter on a website with a block, that refreshes every minute. I have an API where I can get the counter-value. https://myapiwebsite.com/api/checkin/getCounter?token=mytokenvalue ...
-2
votes
0answers
14 views

How to make a slideshow with multiple content per slide?

My group is new to Drupal and we were wondering how to make a slideshow with multiple content and/or images per slide similar to the image shown below.. Those highlighted in blue are supposed to be ...
0
votes
1answer
69 views

How to deal with block cached for anonymous user?

I have placed in the site's home, via twig, a views block of nodes with a random sort and obliviously no cache active. Therefore, at each page reload different nodes appear. The problem is that block ...
1
vote
2answers
88 views

Pass value into a view using block input

I have created a Drupal 9 site with articles that belongs to taxonomy terms. I want to give the ability to the administrator of the site to place a block with whatever taxonomy he wants. How would I ...
0
votes
0answers
23 views

How add a paragraph field to a form programmatically?

I'm on Drupal 9. I am creating a custom block programmatically with some fields in the configuration form. However, I need to add a paragraph field and I've found no documentation\working way to do so....
0
votes
0answers
8 views

Loss of formatting (CSS) when making views blocks

This probably requires an easy fix, but I haven't found the solution for it online so far. Basically I have some specific CSS properties for a Views with an HTML list. Each header section is a ...
0
votes
1answer
30 views

Is there a way to see all the available variables inside content?

I am using Drupal 9 with twig files I have a page where in one section I need to show thumbnails of the latest posts. So I created a new view as a block, and placed this block under Content in admin/...
0
votes
1answer
47 views

Negate a block visibility condition [closed]

Found it useful and did not find any contributed module to fulfil this so, adding it for knowledge purpose. Stuck in a situation where we need to hide a block for certain role. Drupal 8 has ...
0
votes
1answer
40 views

Clearing the render cache after being programmatically logged in

This issue is on a Drupal 8 site. I have no reason to think it would behave any different on Drupal 9. We have a scenario where we are having trouble with caching of a custom block. This block ...
0
votes
0answers
13 views

Show book tree from page on down

Using Views I've created a block which show the immediate children of the current parent book page. What I really want is a block that shows the total child hierarchy of the current parent book page. ...
0
votes
0answers
21 views

How do I get theme suggestions for a custom block attached via an entity reference field?

I have created a custom block type with the machine name "score_card". I am displaying it on a node page via a paragraph with an entity reference field that references blocks. I would like ...
1
vote
1answer
32 views

Template suggestion does not work for table in a custom block / Might there be a way around?

I created a block on pages of the "Author" content type that lists all the articles the author has contributed to in a table (via contextual filter). Now I want to customize the table layout....
1
vote
1answer
27 views

Entityqueue - Get field values from the queue

First off, i'm very new to Drupal. Kindly help me and forgive if im being a noob. Im using the module - Entityqueue https://www.drupal.org/project/entityqueue Im created a view block for a entity ...
0
votes
0answers
26 views

How selectively print the content of region.html.twig

I'm trying to modify the html of region.html.twig I've used a hook to override the suggestion: function my_theme_theme_suggestions_region_alter(array &$suggestions, array $variables) { if($...
0
votes
1answer
19 views

Place custom block on particular content type pages and home page

I have a custom block which I want to place on all the pages of one content type AND on the home page. The home page is a custom twig file that pulls in the region where the block is placed. Right now ...
0
votes
1answer
27 views

Force an image to display as block (not inline)

I have a field of type image that I would like to display in a column alone, with all following content displaying beneath, even if the image width is narrower than the width of the display. Even when ...
0
votes
1answer
28 views

How do I create a block in a module that can be referenced via an entity reference field?

I'd like to be able to reference my programmed block as a field in a paragraphs. I've Generated a module with drupal console - drupal generate:module Used the template for a block from the example ...
-2
votes
1answer
40 views

Getting current user ID in a custom block [closed]

I have a custom block where I need to use [current-user:uid] in just one text. In Drupal 7, I would have used PHP input filter. How can I do this in Drupal 8?
0
votes
0answers
12 views

Hide a block from the “Place block” list

I have a custom module that defines a series of blocks. Depending on the configuration of the module, I'd like to hide blocks from "Place block" block layout list unless they're enabled. Is ...
0
votes
1answer
12 views

Can I add a custom block?

I want to have a block with 3 text body fields. I've done this before in Drupal 8 where I created a custom block and was able to add different fields to it. In my Drupal 7 setup, I can add a block but ...
0
votes
0answers
31 views

I've placed blocks in hidden region, now no login to admin possible

I made a site in Drupal 9. I played a bit with blocks and I think I placed an important block in the hidden region. Now the login page doesn't show the login form anymore. The header, footer and some ...
-1
votes
1answer
32 views

How to render a custom block in a twig file?

I created a custom block named "Alert Bar" in the "navigation" region and I want to render it in my header file. My header file currently has code like this to render the blocks - {...
-2
votes
1answer
48 views

Why is my custom block template not being picked up?

I am working on a custom slider programmatically. I create a custom module (block_example) and make a block (BlockExample.php) and a twig file (blockexample.html.twig) and also a module file (...
0
votes
0answers
18 views

How do I get information from build method into render array and rendered?

I have a region that I need to sometimes render differently, based on a value in the build method. The build array has the correct information, but by the time it gets the preprocessor its gone and ...
0
votes
1answer
18 views

Can use Webform for add combobox for select language on the site?

I want to know how I can add a combobox to a page. For example, on the front page, I want to add a combobox for selecting the language. I use the default modules for creating multilingual sites. ...
0
votes
1answer
22 views

Change max length of title in a custom block added via a template file

A drupal 7 website has a custom block added via a template file. The block displays previews of article content type belonging to a certain rubric. It uses the following line to do so: $block = ...
0
votes
0answers
28 views

Editing block content: empty block body

I've been asked to support a drupal website. The website has a block that has content in it. When I locate the block in /admin/structure/block/block-content, the "block body" section is ...
1
vote
0answers
10 views

Access custom block link field url in twig template

I have a custom block with four fields like this : I want to display in twig the value of image's uri. I've tried something like that in field--block-content--field-linkedin-link--rs.html.twig ...
0
votes
0answers
44 views

Placing a block on an entity

I am aiming to place a block on an entity. It seems like this should be simple as entity integration in D8 is well-developed and (in parts) user-friendly. I can get the view block working fine and can ...
0
votes
1answer
115 views

Show the site name in a custom block

I am working on Drupal 8 custom block. I want to print the site name in this custom block. MyBlock.php public function build() { return [ '#markup' => t('This is a simple block!'), ]; } ...
1
vote
0answers
21 views

Panelizer content missing on module update

I'm in the process of migrating a client's Drupal 8 installation to the preferred composer structure (outside of docroot), but having a single issue causing a full stop. They use Panelizer for most ...
1
vote
1answer
38 views

How do I add a view between display fields of a node?

I have a view that displays a table at the bottom of every node. It's part of the content of the node so I want to have the "comments" section below the view. However, the comments are a ...
1
vote
1answer
53 views

How to display a custom block in a view twig file?

I added a custom block in the header of a view, and I am trying to get it to display. The block contains social media icons and links. If I want to add a custom text area, I can use this code - {{ ...
0
votes
0answers
41 views

Error: setLibraries() must be of the type array

I am trying to integrate a React module into Drupal, my first time trying to do such a thing. I have developed this module locally and it runs fine. When I upload it to my server, I get the following ...
-1
votes
1answer
17 views

Add “Add new content” custom block to a specific page

I would like to add a block which contain a button for when the user click would redirect to the Add new content page with a specific content type. I'm building some sort of a book store a would like ...
1
vote
1answer
25 views

Get list of preprocess block variables

How can I display a list of preprocess block variables so I can conditionally include a library? Using the 'plugin_id' doesn't seem to work and when I echo all of the variables all I see is a blank ...
0
votes
2answers
23 views

How can I prevent a custom block from rewriting HTML?

I have a self-contained widget written by a third party that consists of HTML, JS, and CSS. I've dumped it into a custom block with Full HTML (and verified the Full HTML settings are loose enough that ...
0
votes
0answers
59 views

What is block provider?

I'm trying to create a custom block in Drupal 8 in one of my modules, and have followed the examples I've found in tutorials. But when I try to place the block, I'm getting this error: Notice: ...
0
votes
0answers
83 views

403 Ajax error when trying to place a block

I am unable to place a block. When I click on 'Place Block' nothing happens. When I check the Chrome console, there is an Ajax Forbidden Error 403. Message below. I have both checked Drupal log ...
0
votes
0answers
10 views

Menu Link to views with % in URL

i have the following construct that i have the following URL: /node/nodeid/fooobar Foobar is a view that uses CONTEXTUAL FILTERS to draw the node id and then render the view. This works really well so ...
0
votes
1answer
51 views

Custom block disable caching?

I've created a custom module to show On This Days in a block but they are not changing each day until I flush the caches. I call the entity: public function build() { $query = \Drupal::entityQuery(...
0
votes
1answer
29 views

Media html not rendering in blocks

I'm experiencing an issue on multiple sites where (image) media aren’t appearing in blocks despite working fine in node fields. I first thought it only happened to me when using the linkicon module, ...
0
votes
0answers
32 views

Relative date filter views block is cached for anonymous users

Drupal 7.74, views 3.24 (latest) I have a view which uses a date field to filter and shows on: less than or equal to "now" I display the view in a block. With caching for anonymous enabled, (...
1
vote
0answers
58 views

Use one controller in custom Block and Page

I have a custom module with a page and block. Both will use same API but with different queries and also both will display API data in the same page. To be more explicit, I have a simple search on my ...
0
votes
0answers
33 views

Error displaying block created progamatically

I am trying to create a block with a form to display inside the block. Here is my block <?php namespace Drupal\fixx_helper\Plugin\Block; use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\...
0
votes
1answer
22 views

How do I show an exposed view filter in a block only on relevant taxonomy term pages?

I have two different taxonomy term views for different taxonomy vocabularies: the Blog categories the and Product types. I have an exposed filter in a block that is relevant only for the Product ...
3
votes
2answers
153 views

Can you render a custom block in a view without adding it to the admin blocks page?

I made a custom block in my custom module. I now want to show that block in the "No results" area of a view, but I can't get it to render (I don't see any error message, and I don't see any ...
0
votes
0answers
37 views

Amend footer information

My company site has moved from D7 to D8 this morning. It all looks great (and so much easier to use!), but I can't see how to amend a footer? One of our office buildings changed its name during the ...

1
2 3 4 5
56