Questions tagged [blocks]
In Drupal, a self-contained collection of content and functionality that is displayed in theme regions is called block.
2,746
questions
1
vote
0answers
19 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
36 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 ...
-2
votes
0answers
21 views
What is the best way to show a different phone number [block] depending on the user's geographic location?
We have a Drupal 8 site that displays a company phone number in a standard block. We'd like to display a different phone number depending on the geographic location of the user (North America, South ...
1
vote
1answer
40 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
38 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
16 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
17 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
21 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
34 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
50 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
9 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
48 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
27 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
29 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
37 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
31 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
18 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
138 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 ...
0
votes
0answers
26 views
How can you add a tab programmatically in Manage Form Display for a block
The hook: hook_enitity_base_field_info() and BasedFieldDefinitions allows you to create fields for all the custom blocks. Those fields are then used in Manage Form Display. I want to add a field group ...
1
vote
1answer
43 views
Replace a word in a custom block or paragraph with a token related to a content type field value
I have a content type with a mix of paragraphs and custom blocks.
Most custom blocks (content) are the same on all pages except for one word that needs to be replaced by an other one.
I would like to ...
-4
votes
1answer
30 views
Multiple Gutenberg blocks in a module [closed]
I've created a custom Gutenberg block and would like to know how to add more within the same module. Some suggested to add JS in MY_CustomModule.libraries.yml, but it does not work.
My custom H2 ...
0
votes
1answer
64 views
How can I update the block content programmatically?
I have created a block plugin.
/src/Plugin/Block/Myblock
/**
* Provides a 'Download component' block.
*
* @Block(
* id = "my_custom_block",
* admin_label = @Translation("My ...
0
votes
0answers
12 views
Add row after amount of blocks
I'm trying to archieve something that looks very easy for me, but I can't find the solution. I'm using drupal 9, bootstrap 3 subtheme.
I have a region (region-buttons) that has multiple blocks.
{%
...
0
votes
1answer
13 views
Custom block with a field value that can be used in other twig template
I am creating a custom block with fields:
field_items_to_show (items to show)
field_logos (images, multiple)
The site editor must have the option to set the amount of items to show in a field.
in ...
0
votes
1answer
23 views
How do I run a BrowserTestBase functional test with blocks?
I have a module that defines a custom block and places it using a block.block.block_name.yml file that I generated by exporting the placement of the block on a dev site. I've unit-tested the block ...
2
votes
2answers
151 views
How can I stop the full HTML editor from deleting my <p> paragraph?
https://drupal.slack.com/archives/C1BB308HH/p1602318464360700 Link to slack question in #support
JSFiddle of the offending html: https://jsfiddle.net/tyeth/xr4ohast/
Demo Video showing the paragraph ...
1
vote
1answer
91 views
Returning custom array in lazy builder callback
I have to return a custom array from a lazy builder callback and then loop through that array in a Twig template for a custom block. Here is my code so far:
Custom block:
public function build() {
...
1
vote
1answer
47 views
Block in node view showing but does not show up when rendering node in Views
I have a node type that I have a specific block added to. I have some AJAX going on in the block. When you view the full node the block shows up.
When I go to Views and render the full node content ...
0
votes
1answer
58 views
Custom block build function to display wysiwyg body text
I am learning to build custom blocks through a module. I am trying to get the build() function to work. I have the code and it works. However, if I edit the configuration of the block as a user it ...
-2
votes
1answer
44 views
Custom block theme not appearing in QuickTabs content
I'm attempting to create a dashboard page that contains 4 tabs that are each a block that will contain a content based on the current user. I went ahead and created the 4 blocks (bl1, bl2, bl3, and ...
0
votes
0answers
49 views
Blocks Structure screen not displaying because there are too many blocks
I have a large D8 site and currently have about 400 blocks. When I got to the main Blocks Structure admin page
-- /admin/structure/block -- It now hangs up and will not display. I just get an error:
...
-2
votes
1answer
75 views
0
votes
1answer
38 views
URL-dependent templates only evaluated once, incorrectly cached
I have a twig template that controls the HTML of the page based off of some URL-specific information. However, this template seems to be evaluated once on the server and then gets cached, never to be ...
0
votes
1answer
33 views
Core Update to 8.9.4 Removed Block Visibility Options? [duplicate]
Recently updated core from 8.9.2 to 8.9.4, in doing so the options to place blocks on specify pages is now gone?
1
vote
0answers
17 views
Putting the articles as content
I have a theme with some blocks. I have a problem with adding articles. Right now when I want to add a new article, it appears in each block that exists on the website. How can I put a new article ...
1
vote
1answer
67 views
Block visibility role section is missing [closed]
I am doing development in drupal 8. All of a sudden, I see that block visibility role section is missing.
How can I bring the block visibility role section back?
0
votes
2answers
62 views
How do I add a template suggestion for a Views block?
I am very much so new to Drupal and have moved to this platform after working with Magento for 5 years.
I am trying to create a template for a view. I have created the twig template under /templates/...
1
vote
1answer
38 views
How do I retrieve a plugin block field's translated value?
I created a module that installs a block with some fields when installed. I added a schema file, and altered the blockSubmit() function so that the translation is saved in the schema.
Here is my ...
1
vote
0answers
130 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
33 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
17 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 ...
1
vote
1answer
32 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
45 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(...
0
votes
1answer
61 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
42 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
49 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' => $...
1
vote
1answer
61 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
165 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
57 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' => '...