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

Questions tagged [blocks]

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

-1
votes
0answers
17 views

Display Block After some time using ajax?

I have alter the webform block after some times to display in page. for example. The Block should be display to the user after the one minute. I have rendered the block in some region and the block ...
1
vote
2answers
41 views

Why can only administrators see blocks?

I'm using the Paragraphs and Block field modules to display a list of nodes within the content of a page. This works great while authoring, but as soon as I log out from the administrator account, the ...
0
votes
1answer
23 views

Inject variables from Controller to Blocks?

I have a Product module that implement's an entity, a Repository, a Controller and 2 Blocks The problem is, in the product page, I'm querying the entity in every block and also in the Controller. I'm ...
0
votes
0answers
13 views

Enable block visibility settings within Context

Are there any documented/known ways to enable block visibility settings within Context? I've got a case where I have separate contexts set up for each site language which define the menu blocks that ...
0
votes
0answers
33 views

Block not displayed when form has token [closed]

I created a custom block that appears in the home page. and in the block I have many products . But if i add add_to_cart form for products the block does not appear And I only have the code <...
-3
votes
2answers
38 views

How to change the background color of blocks? [closed]

I just want to change the background color of a block on the “Sidebar First” region in Drupal 8. How can I do that?
-2
votes
0answers
30 views

How do I fix these errors?

I am facing the below errors while trying to add a block inside a region from /admin/structure/block. It is giving a Javascript warning and errors. Please help me resolve this error. I am not sure ...
0
votes
0answers
23 views

How to get views header and footer in view block template

I have created view as block and in block twig template i can print view fields as content['#view'].field['field_machine_name'].value(row) HOw can i print text in textarea that i set as header and ...
0
votes
0answers
43 views

Config block translation?

EDIT - Here is my block src code. The module directory has no other files except the .info.yml: namespace Drupal\config_block\Plugin\Block; use Drupal\Core\Block\BlockBase; use Drupal\Core\Block\...
0
votes
1answer
28 views

How to render a block in a template? [closed]

I installed the module "Shariff Social Media Buttons" for "Drupal 8" : https://www.drupal.org/project/shariff This module once installed, add a block in : /admin/structure/block I want to display ...
1
vote
5answers
181 views

hook to alter custom blocks?

I am having a problem with my custom blocks rendering, and I want to programmatically manipulate the blocks to troubleshoot the issue. I used this question to add this hook to my module: function ...
1
vote
2answers
88 views

Unable to access Views fields in block Twig template

How Drupal 8 uses Twig, how different data is transferred from general template to specific templates? For view block I have created block template as per default template suggestions. In my new Twig ...
0
votes
1answer
11 views

Facet blocks are not appearing, when indexed view block is called programmatically with views_embed_view

I have made an indexed view of my products. In that view, i have a page and a block. If I output the block from drupal/admin/structure/block the block view is shown together with the facet blocks. ...
4
votes
1answer
169 views

Custom blocks not rendering for anonymous users

I recently deployed an update to Drupal 8.6.3 from 8.6.2 on our Drupal-specific managed web host (Pantheon). Unfortunately, I noticed after the update that our site's footer was missing, but only ...
1
vote
1answer
15 views

How do I create a block only for the user “owning” the profile page?

I made so the logged in user have a recap of their last comments/added node on their profile with a view. As I am making the profile page public, I need to be able to hide those blocks from others ...
2
votes
1answer
22 views

Display block content in current language

I have multilingual Drupal 8 site. I want to display views block in home page. It should display block contents in current site language. Example: I have content type called "Book". Which has ...
-2
votes
0answers
25 views

Adblocker blocking ##sponsor-xxx DOM content that aren't ads. How to go about renaming files/references? [closed]

I've been tasked to change a site that we develop for a nonprofit org so that the content showing the sponsors isn't blocked. On loading, there's three DOM files that are being blocked: ##sponsor-logo,...
0
votes
1answer
22 views

How do I use a different structure of a theme on different pages?

The picture shows the block region demonstration of a Drupal theme that I am using. I am new to Drupal. As the structure is given, I want to use different structure in different pages of my site. ...
0
votes
0answers
59 views

Block disappears unless I refresh route and link cache

I have a submenu based on the main navigation menu system. This Plugin Block builds the submenu on every page. The links of course change based on the route. Every hour around the same time, the ...
0
votes
1answer
15 views

Related events block

I have a content type, Venues and a content type Events. In the Events post type, I have 'field_hosted_by' - allowing me to select the relevant venue. On each venue page (/venue/venue-name), i'd ...
0
votes
0answers
40 views

Add class to UL in menu block if block has class

I have a menu that I am display in a menu block. I am using the Block Class module to add a class to my menu block. For example: I have a menu called "About Page Menu" that has 3 menu items. I place ...
0
votes
0answers
32 views

Dynamically set theme per block/paragraph

I'm looking to apply specific themes to individual items on a page - a different theme to the rest of the page. I realise this seems quite obscure, but the general premise is similar to a styleguide. ...
1
vote
0answers
36 views

Same session variable retrieved in different blocks not stable

I have a module that have three blocks. Block No 1 sets the session Block No 2 gets the session Block No 3 remove the session Each block is assigned to a different page. Now, for some reason this ...
0
votes
1answer
42 views

How to render the field from custom block in node.twig

I want to render the custom field from my block in node.twig. As I understand I have to expose the fields from Block to Node variables. How to realize that?
0
votes
0answers
39 views

Custom Block disappearing periodically even cache max-age is zero [duplicate]

There is a Drupal 8 custom block which is created by extends from BlockBase class in the custom module. To make this custom block uncachable, added below code line before return statement. $build['#...
0
votes
0answers
25 views

How can I duplicate the auto-populating feature of the main navigation?

I'm trying to create a menu that is the same as the main navigation, but has its configuration tracked separately. This is important because there are some menu items on the new menu that I'd like to ...
0
votes
2answers
36 views

Where should I place hook_block_view_alter?

this may be a trivial question, but I have no clue to how to get this working. I have this theme 'nexus'. When try the hook function nexus_preprocess_block(&$variables) in the file nexus.theme,...
0
votes
1answer
25 views

Get raw value of a block content

I have created several views. These views have a block display. If I use these blocks in my template, the views are rendered with all the wrappers / divs. In my block template, can I alter the output ...
1
vote
1answer
34 views

How do I verify a block can be shown in the current page? [duplicate]

I created a normal block and configured it using the following settings. I don't want to show the block on node/2 and node/3, for example. I want to get the block render, but verify first the ...
0
votes
2answers
72 views

Disable block caching

I just made a simlple block by using block > custom block, so I didn't make it programmatically. I am a Drupal 8 newbie, and I look for a simple and clear solution how to disable caching for that ...
0
votes
1answer
33 views

How can I (programmatically) display a custom block with user profile links in dropdown?

I would like to display a custom block with some links for authenticated users like drupal.org does. I would like to display username next to user's picture, and custom menu items. For example, "My ...
1
vote
1answer
23 views

How to render a block provided by a contrib module in a node template

I installed Better Social Sharing Buttons and I can not understand how to programmatically display the block of this module in node.html.twig. I display the blocks created by me like this: function ...
2
votes
1answer
23 views

Is there a way to display primary tabs vertical in separate block?

In Drupal 7 I want to rearrange standart drupal tabs (eg. 'View' and 'Edit') as vertical and move it to sidebar. Is there a way to do this?
0
votes
0answers
10 views

The cutom filter block disappears when new search key is entered

I am using the Search API, I have created a /search page for observing the search results based on three entity types. I have two exposed filter: The "Fulltext Search" filter is located in the ...
0
votes
1answer
16 views

Views block doesn't appear on page if only media-type content is selected

I've created a view block that has a contextual filter with a Content ID from URL. The view is only to appear on my content types if the field_aside_content has any data in it. This field is just a ...
0
votes
0answers
43 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
52 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
16 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
22 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
62 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
30 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 - ...
0
votes
0answers
43 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
26 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
38 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
51 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
17 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
71 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
15 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
28 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 ...