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
0 votes
0 answers
3 views

Layout builder + multilingual

I'm currently working on translating a D10 site based on Layout Builder to other languages. As I want the layouts to be the same in every language, but displaying just a translated version, I don't ...
raistlinjoe's user avatar
-4 votes
0 answers
39 views

custom blocks not showing for anonymous user [closed]

I have a custom social sharing block that shows only for logged in users . the block does not show for anonymous users , i have tried everything mentioned here Custom blocks not rendering for ...
Diana's user avatar
  • 3,002
0 votes
0 answers
17 views

The variation price isn't showing on the product page

When I go to a product page the price isn't shown. When logged in as admin I see 'This block is broken or missing. You may be missing content or you might need to install the original module.' and the ...
Martin's user avatar
  • 1
1 vote
1 answer
76 views

How to properly set up caching in a preprocess function for a block variation by node type?

I have a site that uses hook_preprocess_block to add a node content type/bundle variable for a block twig template. The template then has logic to display different HTML depending on the node type. ...
codesmith's user avatar
  • 292
0 votes
1 answer
17 views

Is there a way to create a views block for layout builder where the admin filters the information to be show to the end user?

I have a views block where the views exposed filters is available to the end user. However, I need to allow the content editor to make the selection in the block (to be placed in layout builder) as to ...
user3038672's user avatar
0 votes
2 answers
92 views

Deprecated EntityBlock module preventing upgrade

I have a Drupal 9.5 site that I am attempting to composerize and upgrade to Drupal10. I created a Drupal10 site in a local environment, copied the site content over, and installed all the Drupal10 ...
Justin Desmarais's user avatar
0 votes
0 answers
21 views

Rendering a block programmatically does not render the twig template [duplicate]

I'm renderding a block: $bid = 13; $block = $this->entityTypeManager->getStorage('block_content')->load($bid); $build = $this->entityTypeManager->getViewBuilder('...
Mike's user avatar
  • 11
1 vote
0 answers
47 views

How do I add a custom module block to any theme's bottom-most region programmatically?

I have a custom block in my custom module that I want to appear automatically at the bottom-most region of any theme. I want this to happen when the module is installed. Similar to how the 'Powered by ...
japonix's user avatar
  • 11
1 vote
1 answer
53 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
66 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
  • 11
0 votes
0 answers
120 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
183 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
48 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
46 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
62 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
75 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
76 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
61 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
133 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
233 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
170 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
36 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
63 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,277
0 votes
0 answers
62 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
143 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
  • 123
0 votes
1 answer
94 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
69 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
566 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
155 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
2 votes
1 answer
49 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
69 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
93 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
296 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
  • 1,001
0 votes
0 answers
57 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
116 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
260 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
87 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,388
2 votes
2 answers
566 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
81 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,277
0 votes
1 answer
121 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
243 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
63 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
438 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
71 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
117 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
199 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
33 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
1 answer
963 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
134 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

1
2 3 4 5
58