Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

In Drupal, a self-contained collection of content and functionality that is displayed in theme regions is called block.

0
votes
0answers
20 views

Overwrite default (Bartik) block.html.twig from my custom block module folder [duplicate]

I have a custom block module. I want to override core/themes/bartik/templates/block.html.twig in my-module directory. In my-module directory I have a folder templates/ and the twig file block--my-...
0
votes
1answer
35 views

how to know block id in class which extend from BlockBase

I am trying to get block id in my custom module in build function of class which extends BlockBase. How can i do this? i want to use this block_id in another class controller to have configuration ...
0
votes
0answers
13 views

How to embed a login or register form inside a page content body

First of all I am new to drupal. I am looking for a solution where I can include a login or register form in the body of a page with admin-editable page content/markup flowing before and after it. ...
0
votes
0answers
14 views

Add (background) image field to custom module block

I created a custom block module. How do I add an image field to the block configuration, so the user is able to upload a Background image to the block? Then with a theme hook I want to set image as ...
0
votes
2answers
38 views

How to show entityQuery results as block

I use entityQuery to retrieve nodes related to actual content. Now I don't know how to add them to template and show them in my theme. In Drupal 7 I used Bean module to create blocks as entities. The ...
0
votes
0answers
26 views

Use sub aliases on custom module block to pass parameters

I'm trying to integrate an API into a customers Drupal 8 page. The goal is to show a list and a detail view of job offerings. I decided to create a module with two blocks - one for each use case - ...
-1
votes
0answers
13 views

What is the easiest professional way to convert bootstrap template to drupal theme?

There are some Bootstrap 3 themes that I like and would like to convert them to Drupal. I wonder how I can do it. I went through different guides, but all were for converting basic html css. One way ...
0
votes
0answers
37 views

Pass PHP variables from my custom block to my custom Twig template [duplicate]

I created a custom block module my_block. Inside modules/custom/my_block/src/Plugin/Block/MyBlock.php I have this code: <?php namespace Drupal\my_block\Plugin\Block; use Drupal\Core\Block\...
0
votes
0answers
23 views

Add for loop values and result into custom block and twig file

I have a custom block. In modules/custom/my_block/src/Plugin/Block/MyBlock.php I have some PHP code and this for loop: // Get number of current day. $day = date('j'); // Get number of current month....
0
votes
3answers
32 views

Modify a custom block field value with hook_form_alter and validate

I'm trying to modify a custom block form with hook_form_alter .In its validate function I have a case where one of the field value needs to be unset. For modifying its value I tried with $form_state-...
1
vote
2answers
50 views

Add new column “Block description” on block layout page

I need to add a new column called Block Short Description on Block layout under /admin/structure/block. Can anyone let me know how to achieve it? I have Attached screenshot for reference.
0
votes
1answer
6 views

Views block template print individual field from content

I created a view of paragraphs and I passed the parent ID as the contextual filter using a relationship to the content that use the field that reference the paragraph. I can see the data been ...
-1
votes
1answer
30 views

How can I return HTML form in BlockBase build function?

I include some form from API. And I want to include it in block, using Drupal\Core\Block\BlockBase. My function return HTML tags, that has tag <form>. But function build() return empty array. $...
0
votes
2answers
20 views

Block above content should be simple however

I have a site where they are wanting to have a block above various pages without having a ton of blocks on the blocks layout page. For example they want a block above the login form on the user login ...
0
votes
0answers
13 views

How to expose webfrom content in a block?

I'm building a multi page webform in Drupal 8, and I need to show a summary of content entered on the previous pages in the sidebar. I planned to have a block that exposes values from the form. Is ...
0
votes
0answers
25 views

How to wrap field items referencing custom blocks

I have field of a content type that references custom block entities (created from BO). This field can contain multiple custom blocks. The goal is to be able to theme each custom block in separate ...
0
votes
1answer
16 views

Display a view block on multiple pages

I have a block that I want to display on /group/*. That is working, but it is also displaying the block on /group/*/editwhich is pretty annoying and unwanted. Is there a way to restrict that ? ...
0
votes
0answers
11 views

Bulk upload custom html blocks and/or pages?

As the title suggests, I'd like to know if there's a way to bulk upload custom block HTML files into drupal. I'm new to drupal and I'm being asked to migrate a site that has many content blocks & ...
0
votes
0answers
36 views

new created blocks not appearing

I am working on version 8.5.6 and I have the following issue. Any new block create, doesn't display on the regions of my site. There is no restriction, there is no error log entry related to this ...
0
votes
1answer
27 views

How to add another navigation bar/block at the top of your site?

I want to add a custom header/navigation block at the very top of my page like so, it's essentially a menu item. For example, it has two items: Home and Business. Once clicked it stays highlighted and ...
0
votes
1answer
47 views

How work BigPipe cache around block views?

I have 2 blocks with swiper.js around. This 2 blocks are from the views module. I need to print them in the theme like i want so, i load them into the preprocess_page. $block1 = \Drupal\block\...
0
votes
0answers
13 views

Placeholder for blog “Links” field duplicated, Placeholder for blog “ShareThis” field missing

I am new to Drupal. I am not a developer. Still finding my way around. Please see attached error image. After upgrading to 8.6.1 I now have a duplicated "Links" field for the blog content type, even ...
0
votes
1answer
52 views

how to detect mobile viewport with in twig?

Hey guys is there a way to detect screen display with in twig?, i have a block i want to render in a twig template using the twig tweak module- but only in mobile screen. It is surely possible to just ...
0
votes
0answers
42 views

View block (NOT page) that takes contextual filter argument from URL path component

My question is exactly the same as View block not accepting contextual filter argument but I'm unable to comment and the question never received a valid answer. I want to know if it is possible to ...
0
votes
1answer
38 views

Grandchild nodes (of a nested taxonomy term) on node page

Every time I think I understand relationships… Got desperate and cannot make work following context: A node has a reference (field_a) to a term 1A of vocabulary A. That term 1A itself has a reference ...
0
votes
2answers
33 views

How to change theme template for the same block that is loaded twice on the page?

We have created two menu blocks: main_menu (region=main nav) and main_menu_footer (region=footer) that are added to all pages. They both are displaying the same main navigation menu except ...
0
votes
0answers
36 views

Request query being replaced in a view

I have created a custom block and attached it to a view header. I just can't figure out why the value returned from \Drupal::request()->query->get() is being replaced from views=ajax?...
-1
votes
1answer
27 views

Data in custom-blocks won't get saved

I created a custom block and pasted some HTML containing Hebrew text. The HTML was similar to this. <p><a href="/path">דוגמה</a></p> I saved the block. When I viewed the ...
0
votes
1answer
35 views

How to split region block render?

Is it possible to split the rendering of the blocks in a region ? I have see this question Drupal 8 - How to split display the blocks separately in region.html.twig attempting to solve this by using ...
0
votes
0answers
35 views

Paragraph fields are not properly mapping into the custom block using migration plus yaml

I have created the paragraphs using migration plus module and it is working fine. To map the above created paragraphs to my custom block, I wrote the below YML file. Other block fields are mapping ...
0
votes
1answer
25 views

How to move Contextual Links?

Added a wrapper inside a block.tpl.php called block-content: <section id="<?php print $block_html_id; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>> ...
0
votes
1answer
45 views

Can't find created block

I'm trying to create a custom block programmatically in a Drupal 7 project. I've implemented the two hooks hook_block_info() and hook_block_view($delta=''), I can't find the created block on my_site/...
0
votes
1answer
28 views

Update the block through ajax

I have added a block which shows the no of items added to an entity. I want to refresh the block through ajax as the items are added to an entity through ajax form so whenever I add an item, it will ...
0
votes
0answers
30 views

Block caching prevents the javascript from always being loaded

I have added a custom block and added javascript along with that, But javascript is not working when i enable the cache and on removing the cache, the content doesn't get updated. I have added the js ...
0
votes
1answer
32 views

Hide block if content is empty not working

I want to hide an entiere block is it has not result. I went into my view, then I add "Contextual filter", "Empty", "Hide view". But my view is always hidden if I do this, and I don't understand ...
0
votes
0answers
21 views

Unable to view, configure or disable User Login blocks

I have a User login block that's not visible, configurable or removable on my development server for some reason, even though it works fine on production (I'm managing config using standard D8 config ...
0
votes
1answer
26 views

How to display result of a View in a specific block?

I have a View displaying the content of a Custom Content Entity. The first output I created is a Page display (accessible with a path and an option in a menu). As expected, this is displayed in the '...
1
vote
1answer
36 views

Why is the page content always rendered after blocks displayed on the same page?

I have a Static Page node at, say, /my-page. It has a title and body. I have also placed a block (pointing to a View) in the "Main content" region, at the very bottom of the list. However, when ...
1
vote
1answer
32 views

How can I import a specific type block? [duplicate]

I have created some blocks of a specific type, in Drupal 8, and I want to import them into the cloned instance. There is no core import feature available. How can I achieve the task? They don't get ...
0
votes
1answer
12 views

Views Export button to block

I have a view with Data Export, where it creates a button to download the view's content, depending on a filter supplied by URL query parameters. I'm able to edit the the button using ...
4
votes
3answers
127 views

Change value on validate form when I create or edit a block

I need change a value to element on form validation. I have this code: /** * Implements hook_form_FORM_alter(). */ function MY_MODULE_form_alter(&$form, FormStateInterface $form_state, $...
1
vote
2answers
298 views

Twig template for two different instances of the system branding block

On the block layout page, I added the "Site Branding" block twice, once for normal use (all nodes except content type landing page) and once for landing page use (all nodes of content type landing ...
0
votes
2answers
159 views

Programmatically change block content on page render only

I have a situation where I want to change the content of a block on certain conditions, but not permanently. I'm using a theme_preprocess_block() hook to change the content of the block, but it's ...
0
votes
2answers
23 views

“Login to your account” form block not showing on frontpage when “View published content” is disabled for anonymous

I am new to Drupal 8 but not to Drupal ; In Drupal 8, I enabled the "Login to your account" block in one of my regions : But on the homepage, the block is not showing in the correct region, instead ...
0
votes
1answer
27 views

Why does updating the description of a custom block not update the block title?

When creating a custom block, an editor is required to complete a description field. The description is then used as the block title (if displayed), as well as being used also for admin purposes on ...
1
vote
2answers
122 views

Render custom block using block.html.twig template

I'm attempting to render a custom content block programmatically (created through the Custom Block Library UI) and I would like the block to render using block.html.twig as it would if I were to place ...
1
vote
1answer
26 views

How to load library only on one twig template?

We have a custom theme, mytheme where we have the following library for the header-fix. I have also added {{ attach_library('mytheme/header-fix') }} to only one twig template block--myblock.html.twig ...
-1
votes
2answers
44 views

Show blocks at a specific URL

I'm trying to move some Blocks to a different Page. None of the Blocks are defined in a region. They are specified to display on every Page. In reality, they show up on only one Page. I tried ...
0
votes
1answer
175 views

how to add class to {% block content %} in twig

Here goes my drupal 8 code, so basically block.html.twig is extended to block--mytheme-sitebranding.html.twig. Now I want to add a class to this: {% block content %} {% if site_logo %} <a ...
1
vote
1answer
44 views

How to delete block on hook_uninstall?

I have a custom module, mymodule, that will create custom blocks, block_test and block_test2 on mymodule_install(). When the module is uninstalled, I want to remove any blocks created by mymodule. ...