Skip to main content

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
1 answer
47 views

Parts of the Edit Page

I don't know Drupal, but I need to be able to talk about Drupal with someone and I don't know what to call things, and I can't figure this one out from the rest of the Internet. I have a Drupal 10 ...
Borea Deitz's user avatar
0 votes
1 answer
58 views

Submitting an existing block or form in a modal doesn't work

I am trying to open either the simplenews subsription block or the corresponding form in a modal. I tried with both the form using the formBuilder service or the exising plugin-block and in both cases ...
Mike's user avatar
  • 1
0 votes
0 answers
67 views

Styling a "programmatically created block" in drupal 10

I'm new to Drupal dev, I'm messing around creating some custom modules and explore how the env of drupal 10 works... I've created a custom block that i called "Copyright": <?php declare(...
tsukingo's user avatar
0 votes
0 answers
68 views

Edit existing custom blocks in layout builder

I have an issue with layout builder and existing custom blocks. When I insert existing custom block from custom block library (either create block inline in layout builder, clone it and then try to ...
Ivan Ilic's user avatar
0 votes
1 answer
9 views

Editing block to update/remove menu items

I am new to Drupal and I'm trying to fix items on a website, which have several blocks containing menu items. I don't want to delete the blocks, I just want to edit them to remove/update the menu ...
Karen Petkau's user avatar
0 votes
0 answers
34 views

How do I display the total number of items in a view?

I have a website that works with Drupal 10.2.5 I have 200 articles published. I created a views block with the last 5 articles. I therefore limit the number of elements to 5. I want to display in the ...
marsouin's user avatar
-3 votes
1 answer
57 views

Can I put taxonomy tags in a block and if I can, how to prevent them from appearing in a field of a node?

Having the taxonomy tags in a field of a node in the main content block of the Content region, is a problem for me, as I would prefer having them inside a block so to better choose where they appear. ...
heya's user avatar
  • 1
1 vote
1 answer
52 views

Get block_content from block

What is the correct way to check if a block has an associated block_content instance, and if so, get the block_content object? What I have does not feel particularly intuitive or efficient: /** @var \...
miwayha's user avatar
  • 31
0 votes
1 answer
54 views

Block Plugin not Showing on Certain Pages

This issue has been bugging me for some time and maybe this is just how Drupal is or I am missing something. Anyway, the setup is like this: I have my defined regions on the site. One region is Hero. ...
rtoombs44's user avatar
0 votes
0 answers
43 views

How can I programatically add a paragraph type field to custom block?

Currently, I already built a custom block programmatically, now I want to add a paragraph-type field programmatically to this block but don't know how to do it. The reason is that I want to add/remove ...
huyleuit's user avatar
1 vote
2 answers
101 views

Block config not saved apparently due to an enforced 303 status

After upgrading from 10.0 to 10.1.7, changes to block configuration were no longer saved. I cannot reproduce this in an out-of-the-box instance. I've turned off all custom modules and as many of the ...
JAyenGreen's user avatar
-2 votes
1 answer
141 views

Is there a Drupal way to make a menu horizontal and responsive and leveled (similar in style and behavior to a main navigation menu)? [closed]

I have added a menu to a block in a full width region but my problem is that this menu appears vertical and I didn't find a way in Drupal to make it horizontal, similar in style and behavior to a main ...
drupaler's user avatar
0 votes
1 answer
110 views

creating a webform block that can be used in Layout Builder

My problem is I've created a webform block type, and I can access it from Layout Builder, but when I place the block on a page in Layout Builder, I'm warned "This block is reusable! Any changes ...
Pat Leonard's user avatar
0 votes
0 answers
23 views

Cart Block Does Not Exist After Placing Block in Header, Main Content, Sidebar, or Footer

Drupal: 10.2.1 Commerce Core: 2.37 (Latest) I am creating a new store and I have correctly set up my store, products, product types, product variations & variation types. All of the product ...
Mathias Rauls's user avatar
1 vote
0 answers
54 views

Is it possible, with Twig Tweak or any other means, to place a menu block in a specific language?

I want to place a menu block in a template, but ensure it is always displayed in a specific language regardless of whether the content node where it appears is in that language. I do not ever want ...
arnoldbird's user avatar
  • 1,237
0 votes
0 answers
56 views

How to use the user ID in the "more" link of a views block?

I created a media field for users. Users can therefore add media to their profile. I want to display their media on their user page. I created a media view block with a relationship "Connects ...
marsouin's user avatar
0 votes
1 answer
100 views

Programmatically delete blocks

Is there a way to programmatically delete blocks in a Drupal 10 site? I need to delete the Powered by Drupal block.
Richard's user avatar
  • 113
0 votes
1 answer
93 views

How to let users write private letters to me about a node?

I want to let users the ability to write personal letters to me based on nodes they read while letters are stored in the Drupal database itself (no emails involved) and will include these fields: ...
alesios's user avatar
  • 41
0 votes
0 answers
28 views

Get current node url in a custom block [duplicate]

I'm trying to embed Discourse comments in Drupal, so I'm tryinig tu use this code snippet in a custom block : <div id='discourse-comments'></div> <meta name='discourse-username' content=...
Vanessa Lambert's user avatar
0 votes
0 answers
54 views

AjaxResponse in build() custom block

I want to add an AjaxResponse in build() custom block public function build() { $build['content'] = $this->getContent('field_header_text'); return $build; } This basic code works and I ...
Joouul's user avatar
  • 1
0 votes
0 answers
485 views

How to access Layout Builder blocks in nodes quickly?

Core version 10.1.6. with Olivero theme. My problem is that accessing layout builder blocks, especially in nodes, takes me much time. For example, my homepage has several large "Hero"/"...
ali's user avatar
  • 3
0 votes
0 answers
119 views

Error with Quick Node Clone module - Non-reusable blocks must set an access dependency for access control

I am on Drupal version 10.1.6 and am using the Quick Node Clone module (v1.16). I can clone any nodes/pages and that all works fine. Most of my pages, if not all, are using layout builder where I can ...
Akbar Bakhshi's user avatar
1 vote
1 answer
40 views

How to convert context_definitions to PHP attribute syntax?

Drupal 10.2 enables PHP attributes to be used instead of annotations. So I tried to create some PHP attributes for one of my blocks: /** * Provides an 'Ebook Navigation' Block. * * @Block( * id =...
Patrick Kenny's user avatar
-3 votes
1 answer
66 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 ...
ali's user avatar
  • 3
-2 votes
1 answer
76 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-...
huijing's user avatar
  • 209
3 votes
1 answer
241 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 ...
Giuseppe's user avatar
  • 971
0 votes
0 answers
49 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 ...
user3038672's user avatar
1 vote
0 answers
96 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 ...
ice70's user avatar
  • 131
0 votes
1 answer
203 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 ...
LordCaosWInc's user avatar
0 votes
1 answer
69 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,...
KTM's user avatar
  • 2,362
2 votes
2 answers
474 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 ...
jackrabbithanna's user avatar
1 vote
1 answer
51 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/...
arnoldbird's user avatar
  • 1,237
0 votes
1 answer
98 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 ...
Jordan's user avatar
  • 49
1 vote
1 answer
221 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 ...
Marko Savic's user avatar
1 vote
1 answer
57 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 = $...
jp1977's user avatar
  • 21
0 votes
1 answer
340 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 ...
Harvey Johnson's user avatar
0 votes
1 answer
56 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 ...
micbay's user avatar
  • 13
0 votes
1 answer
79 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 ...
micbay's user avatar
  • 13
0 votes
0 answers
158 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 ...
Bohdan V.'s user avatar
0 votes
0 answers
31 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/...
user111115's user avatar
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\...
Matoeil's user avatar
  • 3,443
0 votes
1 answer
796 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 ...
Alex Monaghan's user avatar
0 votes
1 answer
106 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> <!--...
somo's user avatar
  • 23
0 votes
0 answers
50 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 ...
nihdrupal's user avatar
1 vote
0 answers
20 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 ...
Ricardo Castañeda's user avatar
1 vote
1 answer
146 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 ...
Sébastien Gicquel's user avatar
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); $...
Jaypan's user avatar
  • 17.6k
0 votes
1 answer
111 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 ...
fallenturtle's user avatar
0 votes
1 answer
299 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 ...
user92354's user avatar
0 votes
1 answer
723 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 ...
lobafox's user avatar
  • 123

1
2 3 4 5
58