Questions tagged [blocks]
In Drupal, a self-contained collection of content and functionality that is displayed in theme regions is called block.
2,876
questions
-3
votes
1
answer
54
views
How to unlink the site name?
Core with Olivero theme.
The site name is a link and I want to unlink it.
I want to do it because I already link to the homepage from the main menu and don't want two links to the homepage from the ...
-2
votes
1
answer
26
views
Is it possible to make a theme hook suggestion for blocks according to content type?
I was hoping it was possible to do something similar to this for menus:
* Implementation of hook_theme_suggestions_HOOK_alter() for menus.
* * Make menus themeable:
* e.g. => menu--main--node-...
3
votes
1
answer
168
views
Is possible to have OR logic on block visibility?
I am on D10.
I need to place several blocks on Block Layout having different visibility conditions: for example one of them should visible BOTH in the home page and in every article of the site.
I'd ...
0
votes
0
answers
44
views
New for/if requirements in twig break bc of additional condition
Our content editors have the option of placing a button block in layout builder with a series of buttons on two rows if checkbox is checked. If checked, the value is "On". This worked in ...
1
vote
0
answers
82
views
Disable custom module Block Caching or force correct caching
I have build a custom module that builds out a list of child page links based on 'this' page's id.
Logged in it works as expected. But an anon user has problems which range from the block not showing ...
0
votes
1
answer
76
views
Create tabs with paragraphs and Bootstrap tabs
I'm working on a project that consists of transferring a laravel website to drupal.
One of the features that I'm having difficulty recreating is separating content information into tabs.
This content ...
0
votes
1
answer
53
views
Image field and links not showing in view block template
I have a CT team_members with the following fields.
field_team_member_image
field_team_member_name
field_member_designation
field_social_media_links(Multiple values with links to twitter, instagram,...
1
vote
2
answers
153
views
Get the view object in a custom block plugin
In Drupal 10, I want to create a custom block plugin. Blocks instances of this new block type would be placed in a region on a View page.
How can I gain access to the View object from a programmatic ...
1
vote
1
answer
33
views
How can I get the numeric ID for a block from within the block template or hook_preprocess_block?
How can I get the numeric ID for a block from within the block template or hook_preprocess_block().
By numeric ID, I mean the ID that we see in the edit link for a block. For example, mysite.com/...
0
votes
1
answer
60
views
How to use node context in custom block plugin to get correct revision for node and its fields?
Background information for this question can be found here: How to have a different hero image per node?
I have written a custom block that takes the data from this "hero" paragraph and ...
1
vote
1
answer
74
views
Why do routes created in a React router that do not exist in Drupal give a 404 when I reload the browser?
I have a Drupal 10 site with one page at the following URL: localhost:9090/my-page. On that page, I have a Drupal block that includes a React app with its own Browser Router.
React BrowserRouter ...
1
vote
1
answer
49
views
How to programatically load the blocks that are shown on a specific page?
I need to programmatically update the paths for blocks that are displayed on a specific page, I can load all blocks using:
$nodeStorage = \Drupal::entityTypeManager()->getStorage('block');
$ids = $...
0
votes
1
answer
84
views
How to create reusable custom block templates or duplicate existing blocks?
Drupal noob here.
Problem: Unable to reuse blocks created using Bootstrap Layouts module; being forced to manually re-enter data in order to duplicate a block in a new locaion.
Details and any ...
0
votes
1
answer
27
views
How to pass block instance configuration settings to TWIG template?
I've got a custom block plugin which has some configuration settings that can set from the block configuration form. How can I then access that configuration info later when the block is being ...
0
votes
1
answer
40
views
How to Save Configuration Data for Custom Block
I'm have a custom module that creates a custom block plugin, but am having trouble figuring out how to add some custom configuration settings to the block.
Just for understanding how to do this, I've ...
0
votes
0
answers
80
views
How to run drush cim command for importing all the configurations
I cloned the drupal project on my local.
I have a Docker desktop app.
so I run docker-compose up -d on command prompt.
docker-compose.yml:
services:
mariadb:
image: wodby/mariadb:$MARIADB_TAG
...
0
votes
0
answers
21
views
How to access Block Layout data and add to render array for rendering in a Twig template?
I'm a relatively new Drupal developer, and this ticket for my job has been proving extremely difficult for me to figure out through research.
I want to access the block layout data (/admin/structure/...
0
votes
0
answers
45
views
custom block field not translatable [duplicate]
i have created a custom block
<?php
namespace Drupal\amu_external_search_block\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\...
0
votes
1
answer
270
views
Custom block not showing
I created a custom block module (nothing fancy, just an A-Z list and a taxonomy list for navigation), this worked fine in D8 & D9, now since upgrading to D10 it only shows when logged out, when ...
0
votes
0
answers
19
views
How to show/hide a webform block on nodes of specific content type based on node field value?
I have a webform with machine name "podcast". I am displaying this webform as a block in the nodes of content type with the machine name 'podcast'.
There is a file field with the machine ...
0
votes
1
answer
74
views
Why is <br> changed to <br />?
After I edit a block in Full HTML form CKEditor on Source mode and save, Drupal changes <br> to <br />.
Drupal also seems to me to unify some HTML tags into one line.
This
<p>
<!--...
0
votes
0
answers
44
views
cant wrap element created twig
I made a custom menu and I want to wrap an element with parent element through a script.
element create from block-menu.html.twig
Element: <li class="menu-item menu-item-level-1">
my ...
1
vote
0
answers
17
views
Configure the visibility permissions of single specific block inside Context (not using reaction)
I have a question about Context module and Block permissions.
The project has a context with a reaction that adds blocks. There are many blocks. I want to hide a single block for anonymous users.
My ...
1
vote
1
answer
94
views
How to invalidate custom block which use Cache Tags and Cache contexts for authenticated user?
I'm working on an application where authenticated user data mostly comes from an API.
Performance is significantly better since I'm using the API cache. Before, to be sure to have up-to-date ...
0
votes
0
answers
39
views
Programmatically render block content render array with wrappers [duplicate]
I'm trying to render a custom block, created through the UI, programmatically with a wrapper. I can do this:
$block = \Drupal::entityTypeManager()->getStorage('block_content')
->load($bid);
$...
0
votes
1
answer
84
views
How to make it so theme function isn't used when editing a node with layout builder
I have the following two functions in my .theme file that I'm using to gleam various bits of information from both the path alias and internal URL of the page being viewed. They are:
function ...
0
votes
1
answer
117
views
When iterating over multi-value fields is it considered best practice to override the field template vs loop over the var in node or block template? [duplicate]
I have a link field that allows multiple (3 max) values on a custom block for which I'm using a twig template.
I want to iterate over the values using a for loop.
I got this to work the way I wanted ...
0
votes
1
answer
298
views
Adding cache tags to custom block
I have a custom block which load some taxonomy terms.
When I made changes to my taxonomies, the block isn't loading the new data (due to the cache). I'm passing all my taxonomy tags to my #cache ...
0
votes
1
answer
61
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 ...
0
votes
0
answers
10
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
43
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 ...
0
votes
1
answer
59
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
38
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
votes
2
answers
164
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
94
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 ...
0
votes
0
answers
99
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 ...
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
147
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
294
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
113
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
27
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
65
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 ...
-3
votes
1
answer
165
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
284
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
405
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-...
0
votes
0
answers
58
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 ...
0
votes
0
answers
30
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 ...
0
votes
0
answers
148
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 (...