Stack Exchange Network

Stack Exchange network consists of 175 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.

-3
votes
0answers
27 views

How do I change header and footer based on URL?

I have a custom header and footer for the front page. I would like to change them for some pages. For example, initially I have the image a.png in the header; after clicking the entry form, the ...
-2
votes
0answers
14 views

Editing Sidebar Contents

I am new to Drupal. How can I edit sidebar contents? I have googled the issue without success.
-3
votes
0answers
14 views

Theming and render search block form [closed]

Hello! I wanted to display a click search block in a pop-up window and change its wrapper. How can I do that? As I understand it in Drupal 8 there is no template for this block out of the box.
0
votes
0answers
9 views

Use machine name of blocks from parent theme

I have created a drupal 8 subtheme. I have some blocks that have twig template overrides in the parent theme based on custom block machine names. For example mywackynavbar. In the subtheme, I ...
0
votes
1answer
21 views

Block machine name is in use that is not available

I have a Site Branding block I style in my theme. To do this I give it a specific machine name, in this case: sitelogo On a site using that theme I am trying to create this block but when I try to ...
0
votes
0answers
17 views

How to keep a Form in a Block unique? [duplicate]

I have created a custom block containing a form. It works as long as there is only one block per page. But if there are more than one of these blocks, then the forms are not handled as unique forms. ...
0
votes
1answer
36 views

how to change h2 tag for div in block_view

I've created a block like this function mymodule_block_view($delta = '') { if($delta == 'myblock') { $block['subject'] = 'mytitle'; $block['content'] = myfunction(); } ...
0
votes
1answer
31 views

How do I include an affiliate script?

I am trying to add an affiliate script to my Drupal 7 website. I am doing this in a custom block. Specifically, I create a block, select the scripts text format in my WYSIWYG Editor, add the script ...
0
votes
0answers
21 views

Need to add custom block have previous, next and up links for book page

I am stuck in an issue where I need to create a side bar block on book pages. This block will contain links for: previous chapter, next chapter and up level. Tried searching on google. Also, tried ...
0
votes
2answers
48 views

Block machine name [duplicate]

How do i get the block machine name $block_id programmatically in Drupal 8? $block_id = 'machine_name_to_determine'; $block_config = \Drupal\block\Entity\Block::load($block_id);
0
votes
0answers
13 views

How do I make common blocks appear?

On Drupal 8, I am using the Search API and the Views modules to show search results in page mode. However, I am not able to find a way to display the generic blocks like NAV and Footer on this page. ...
0
votes
0answers
19 views

Access to a block view in a paragraph

I created a paragraph in drupal which has a reference to a block. In the preprocess I did : $variables['bloc_video'] = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($bp); ...
0
votes
2answers
45 views

How do I display username in a custom block?

Am new to Drupal so this is a very fundemental question. How do I display the current username ? In a custom Block? I beleive is the $user->name session variable. Do I create a Custom Block Type?...
0
votes
0answers
20 views

How can I add custom field to menu block?

I want to display a menu in my theme with an editable background. So I'm trying to add a custom field of type image on my menu block. I tried via HOOK_entity_base_field_info but it seems that block ...
0
votes
0answers
16 views

Changing the style of a specific block

I need to change the color of a specific block in Drupal. But no matter what I try in CSS it does not work, I know the code is correct as I have tried it in a different scenario (in Codepen) and it ...
0
votes
1answer
37 views

How do I show a block in a region?

All blocks in the footer region use a CSS grid system. I want to add a <div> with CSS attributes to each (custom) block in the footer. The code I have will show the blocks in the footer, but ...
0
votes
0answers
18 views

Access image field URL in a custom block [duplicate]

I need to have an easily exposed to user background image in an aera (header). So i made a custom block with an image field and i want to use this picture in a classical <div style="background.... ...
1
vote
0answers
30 views

Make EntityQuery Block Table sortable

I made a custom EntityQuery Block Plugin with a table output and managed to make the headers sortable using this $header definition: $header = [ 'title' => [ ...
0
votes
1answer
26 views

How to make custom blocks print unsanitized markup

Goal: I like to create a block to display phone no and a link as shown below: Structure > Block layout > custom block > Add custom block, added this: When I go to my site, I see this: How can I ...
2
votes
1answer
39 views

How to create a textfield with autocomplete function for the view?

My Drupal 8 website is multilingual, and on one of the views I present a list of nodes (titles). On top of the page I need to implement a textfield with autocomplete function, where the user can start ...
0
votes
1answer
20 views

Why do my main menu tabs show up on two lines instead of one?

In Drupal 8, I have a main menu in the "Primary menu" block of the default Bartik theme. You can see a screenshot below. This site was upgraded from Drupal 7. Why does the menu show up on two lines ...
0
votes
1answer
11 views

Only the word “array” gets printed when I try to render custom block in template

I am building a custom block in a module, like this: <?php function filterblock_block_info() { // Sökfilter till temperaturöversikten. $blocks = array(); $blocks['filterblock-temperatur'] =...
0
votes
1answer
41 views

How to create entity within blockForm?

I would like for users to be able to create new paragraph entities within the form of a custom block instead of going into the linked content type and adding the content. In the past, I've always ...
0
votes
1answer
47 views

How can I create Change Password block?

We can create reset password block by \Drupal::formBuilder()->getForm('Drupal\user\Form\UserPasswordForm') in d8, but change password block \Drupal::formBuilder()->getForm('Drupal\user\Form\...
0
votes
0answers
31 views

Views block doesn't show up at the user profile page

I created a views block and try to make it appear on the user profile page. I did the following steps, but it doesn't show up: Block layout -> Place block Tab Pages: Select "Show for the listed pages ...
0
votes
1answer
31 views

Clear region with menu's per url cache

I have a region with menus, a menus displays depending on the url example if on the about page(sitename/about-us), display about menu and links as a sub menu. It works, but the problem is after ...
-1
votes
1answer
36 views

How to let content editors use pre-defined block-like content?

In wordpress (gutenberg), content editors can choose some kind of pre-defined blocks to their content. If I have content editors, that can create new nodes, I want them to be able to add such blocks ...
0
votes
2answers
31 views

Show View When Empty and Hide View When Not Empty!

I have a webform as a block which sets a value connected to the logged in user. I want to display the webform if it hasn't been filled in yet by authenticated users, and hide it when it has (based on ...
0
votes
1answer
21 views

“Expand all menu links” Menu Block selection shows all menu items in block not just active trail items

I have a menu block that I have setup with Initial visibility level = 2 and Number of levels to display = Unlimited. When I check the "Expand all menu links" checkbox and view my menu block it is ...
0
votes
0answers
36 views

Is there a setting to turn off block caching per block / block type in the admin UI?

I want to display the date in a block and make sure that it is always up-to-date (i.e. not storing an old cached value). Currently the date does not change, unless the cache is cleared ( via admin/...
1
vote
1answer
41 views

How many blocks can be handled?

I migrated to drupal 8 and now it has 760 blocks. I plan at least to triple this number. Blocks are placed into nodes content with Insert Block module. When I was setting up website the database was ...
0
votes
1answer
15 views

Print custom field in user edit form in block

Following code prints user edit form in block: function notifikacie_custom_block_info() { $blocks['user_profile'] = array( 'info' => t('User profile edit'), 'cache' => DRUPAL_NO_CACHE, )...
0
votes
0answers
31 views

Embed user edit form in a block

I am trying to embed current user edit form in block. Actually I want just to embed some of the newly added fields. I tried to follow this code: Embed some user profile fields in a block form But I ...
0
votes
0answers
13 views

“CiviCRM Upcoming” block displaying old events

Currently running Drupal 7.61 with CiviCRM 5.7.2. We have the "CiviCRM Upcoming" block enabled in our sidebar, however it continues to display events after their start date. I've been fixing this ...
0
votes
1answer
48 views

Restrict block visibility by page url

Can I restrict the block visibility only show for /worker/*/ but not /worker/*/...?
0
votes
2answers
50 views

How to create a sponsors logo block?

I have some experience with Drupal 7, but not that much. Now I'm working on my first Drupal 8 website and stumbled over the following situation: In a first iteration, the website should use the ...
0
votes
1answer
38 views

Custom block and menu caching

I have a custom block building a menu. The cache works fine until a menu item is enabled/disabled in the menu edit, e.g. admin/structure/menu/manage/main toggle the enabled checkbox and save. The ...
0
votes
1answer
20 views

Entityform view block not displaying on page

I can't seem to get Views-based blocks to show up on an Entityform page (Drupal 7). The View has a Contextual Filter of "Entityform Submission: Entityform submission ID". For the "When the filter ...
0
votes
1answer
46 views

How can I get the current node view mode and add to block template suggestion?

In my code, I need to get the current view mode of the node to be able to pass it to be used as a block template suggestion. The function I have set up is able to grab all available view modes, but I ...
1
vote
2answers
49 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
27 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
25 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 ...
-3
votes
2answers
170 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
1answer
57 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
1answer
64 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
347 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
433 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
14 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
215 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
18 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 ...