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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

0
votes
1answer
9 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
24 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
0answers
22 views

How can I import a specific type block?

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
0answers
8 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 ...
-1
votes
0answers
27 views

How do I use Alfresco's Angular component?

I followed the Creating your application with ADF tutorial to just use the Alfresco Content Services. I am planning to add this Alfresco's Angular component in a Drupal 7 site, maybe as a web page, or ...
3
votes
1answer
71 views
+50

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
48 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
40 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
19 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
26 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
59 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
20 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
36 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
0answers
40 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
29 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. ...
1
vote
0answers
49 views

Get a block by its ID

In Drupal, there are two different kinds of blocks: content blocks and plugin blocks. We get content blocks like this: \Drupal\block\Entity\Block::load('block_id'); and plugin blocks like this: \...
0
votes
2answers
36 views

Breadcrumb in drupal

I want to breadcrumb in drupal8 that display as url as home / list page / node page. I just have in breadcrumb home > node page. I use bootstrap breadcrumb.
0
votes
1answer
18 views

Link translation for custom block

I'm here I need to create a link to three languages. for example <div class="link"> <div class="1_link"> <a href="/en/link/1"> Link 1 </a> </div> <div ...
1
vote
1answer
17 views

How do you render a Node's Last Saved date in a Region Footer (ie, inside a Block on every page)?

I'm new to Drupal (8) and have no PHP experience, but I've managed to get this interesting CMS doing just about everything I need by playing with Twigs. I cannot for the life of me figure out how to ...
0
votes
0answers
18 views

page.content displays content even if the block is empty

The Main Content region has not active block, but it display titles. This is the list of blocks. Why isn't the Main Content region empty?
0
votes
1answer
16 views

How to add a block to a region in html.tpl?

I'm using Drupal 7. I have a custom template html--custom.tpl.php. I have a custom block that contains the main menu. This block is enabled in the header region of block admin. Up to this point, ...
0
votes
0answers
6 views

Displaying posts of each taxonomy term (category) in a view

I have 4 post categories: News, Opinion, Interview, Research. Each post has a related country. I want to display a page for every country, given the country ID via URL, and then inside this pages ...
1
vote
0answers
35 views

How do I assign a region to programmatically created block?

Hi after following this guide I was able to create multiple blocks. But I have couple of issues. Blocks are not created instantly need to clear cache but cant find a way to do it instantly (solution ...
0
votes
0answers
15 views

Not seeing file upload destination radios for image field in custom blocks. Where is the fault?

Scratching my head with this. I am working with a custom block and have added an image field. However the Upload destination radios are not present and this results in a file storage error. ' Illegal ...
0
votes
1answer
16 views

How to check the value of a field within the current node?

In order to display a block only above certain nodes of Article content type, I created a boolean field with two values : On / Off The goal is to display the block only above the articles that have ...
0
votes
0answers
22 views

Returning BinaryFileResponse to Custom Block

Alright, so I have a custom block that is implements a build() method. I also have a controller which loads in terms and should they pass certain requirements, it will return a binary file response, ...
0
votes
1answer
24 views

Message contextual filtering

I have been trying out the Message module. I am using it to send notifications to users' profiles whenever a node of a certain content type is added (a simple hook_node_insert() in combination with ...
0
votes
2answers
45 views

Allow users to use embedded HTML tags in custom blocks

I'm using CKEditor in Drupal 8 and the client wants to write HTML that contains embedded tags like so <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#...
0
votes
2answers
34 views

Placing the Rocket Chat block on a page

I'm trying to include a Drupal 8 Rocket Chat plugin module in my website. I installed the plugin module, set up a chat server, but I'm failing, of all places, at actually placing the block on a page (/...
0
votes
1answer
33 views

How to remove block from the page based on cookie value?

We have a block (myblock) that is only displayed on 4/5 content types. When a cookie, mycookie, is set and has a value of allow, I want to load the block on the page, but if the value is not set to ...
0
votes
1answer
45 views

Custom block automatically adds code when edited in admin

I have written some HTML in custom block, but every time I open the editor in Drupal Admin UI some extra code is added to the block. Essentially, this means I have to remove the added code every time ...
1
vote
1answer
137 views

How do I create multiple blocks?

I would like to create multiple blocks using the data rendered from the variable table in Drupal 8. I was able to achieve it in Drupal 7, but I can't find a way to do the same in Drupal 8. The code I ...
3
votes
1answer
20 views

How do I include a React app?

We are moving towards a hybrid-headless model with Drupal 7. All our data is exposed through RESTful and I have successfully built React app using the data. How can pull that app in as a block? I ...
1
vote
0answers
15 views

Error messages don't work with a render block

In my template.php file, I added function MYTHEME_preprocess_node(&$vars) { $block = block_load('my_module','my_delta'); $render_array = _block_get_renderable_array(_block_render_blocks(...
0
votes
0answers
21 views

Show a custom block when a search term is entered

Using Drupal 8 and Solr I'd like to show a custom text block when a user enters a specific search term on the search page. When a user types in a search term, the query is posted in the URL (ex: ...
1
vote
1answer
52 views

Different content in a block per page

I'm using Drupal 8. I have a content type of “course”. Each course should have a “Banner” block in it that we can upload different background images to (per course). I've created a “custom block type”...
0
votes
1answer
15 views

Hide blocks from the administration page according to the user role

Is there a way that certain roles can only manipulate blocks that are assigned to them? That is, if a user with an a editor role enters to "admin/structure/block", I just want you to see and be able ...
0
votes
0answers
34 views

How to Render / Print Values correctly from Custom Blocks using Paragraphs via Entity Reference?

I've been trying to render/print the data from my custom blocks using paragraphs via entity reference to my twig template. So far I've managed to test and successfully print the data to my twig using ...
0
votes
0answers
35 views

Simple condition evaluate not called

I have the following condition that check if a node has field_tags to return true <?php namespace Drupal\custom_conditions\Plugin\Condition; use Drupal\Core\Condition\...
2
votes
1answer
45 views

Display block if content type has entity reference (tags) that contains specific term

I want to display a block when a node contains a entity reference field when specific term is present. I have tried numerous modules that did not work for me or perhaps I did not set them up right, ...
0
votes
1answer
48 views

Display a block based on current select option

I have a select field that holds two options. When the second option is chosen, I want to display a block. I know that with form API I should be able to do this. I'm just not sure on where to start. ...
0
votes
1answer
29 views

Trying to Conditionally Add JS File to page if in a paragraph block reference on that page

I am not sure how to accomplish this... I want to have a custom block that I have created and referenced via paragraphs to implement code in that block and push it into the header of the page. The ...
0
votes
1answer
28 views

Add a Block ABOVE view

I need to add short descriptions for some 20+ views and display them above the views. I know I have an option to add a header to a view, but that's not what I want. I have a sidebar on the left and ...
0
votes
0answers
24 views

Option to display/hide block dependent on content type gone

I have a drupal 8 site, on which I have several blocks that I want to hide on pages of a several content type. I have done this before. Usually, I go to structure > block layout, select edit on the ...
0
votes
1answer
18 views

See Which User Created/Edited Block?

Is there any way in Drupal 7 to view which user last made edits to a particular block, or who created the block?
1
vote
1answer
83 views

How to wrap views-view-fields.html.twig with html container element?

I have a block view with an image field. I know how to theme this field : views-view-fields—my-images.html.twig How can I wrap this loop with an element like : <div class="slider-article"> I’...
0
votes
0answers
22 views

How do I call a block through a JS routing [duplicate]

I can render a form in the controller from the below code \Drupal::formBuilder()->getForm( 'Drupal\custom_form\Forms\myForm' ); Is there a way to call a block from a controller like this? I ...
0
votes
0answers
19 views

How to translate file field from a plugin block?

I have generated a simple plugin block with Drupal Console. I have added a managed file field during the generation process. Then I would like to translate this block. Unfortunately, this block does ...
0
votes
2answers
20 views

Using theme hook, how do I get block contents into the $comm line?

if ( isset($vars['content']['#block_content']) ) { // check for custom content if ($vars['content']['#block_content']->type[0]->getValue()['target_id'] == 'js_file_block') { // only run on ...
0
votes
0answers
24 views

How to create a custom paragraph block that preprocesses multiple Javascript Files?

I am trying to create a custom block that preprocesses inputted JS files in a node to load in the header of specific pages that have that block reference in a paragraph. if ($vars['elements']['#id'] =...