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
1answer
39 views

Adding a view block to a basic page

I have been tasked with creating a new basic page that contains displays, the content of some new content type. So far, I have created the basic page and I have also created a new view block (i.e. I ...
0
votes
0answers
21 views

Creating block of category 'commerce' to show shopping cart contents

I am new to drupal, and am trying to create a commerce page. I have created a basic page, and I am now trying to add a block which lists the products in the shopping cart. I am using an existing ...
0
votes
1answer
39 views

How to Make Managed File Field Available to Twig Template?

I am wanting to make it so that users can upload images to a block configuration form for a pre-existing (views-generated) block (views_exposed_form) and have the images available in the block's ...
1
vote
1answer
33 views

Duplicating content blocks

Is there a way to clone or make copies of blocks? For example, we have some blocks that are quite bespoke. We need to make multiple copies of them so we can display certain content within them on ...
0
votes
0answers
30 views

Save value in form with multiple instances in same page

This is my buildForm function: class NewsletterForm extends FormBase { // ... public function buildForm(array $form, FormStateInterface $form_state, $newsletter_list = NULL) { $form_state->...
0
votes
1answer
39 views

How do I identify what type of data or object I have? It's a referenced entity

I am new to Drupal but an experienced developer. I'm creating a DS field in which I will display a custom block chosen by the content editor. I have successfully gotten a referenced entity (two ...
0
votes
0answers
11 views

Ajax loader when facet is selected

When we add a facet block to the page, a filter is selected and the page starts to load the results. However there is no loading icon or indicator the change is being applied. When we check the page,...
0
votes
1answer
22 views

Render image field with custom image style in custom block template

This is basically the same question as this, but I can't get the technique to work in a custom block type template: https://drupal.stackexchange.com/a/219052/71100 I have a custom block type called ...
-2
votes
0answers
13 views

CKeditor accordion does not install with configuration menu

I have installed the CKEditor accordion using this guide https://www.ostraining.com/blog/drupal/accordion-button-in-ckeditor/ Yesterday it was working, but today when I install it does not add the ...
0
votes
0answers
46 views

Why Form Api behaves differently in route and in custom block?

I’ve encountered this issue several time and I don’t know why. I know this not so easy to reproduce but maybe someone has an explanation. I’ve built several custom modules which return datas from ...
0
votes
0answers
13 views

Adjust block according to stage in multi-step form

I've build a multi-step form using the following tutorial. Which is quite nice! Can I also change a block based on the step you're in? I'm my case I have an activity registration form, build ...
0
votes
2answers
24 views

Customize the title field

I want to display updated content's field with views block on the front page. 2019/06/20 newly posted content1-title 2019/06/19 updated content2-title The words updated and newly posted before the ...
0
votes
1answer
17 views

Display Suite Token Fields in Custom Block Types

I want to add a Display Suite token field to my Custom Block Type. I have a custom block type. I created a token field with Display Suite Entities: Block Content Limit field *|* or link_card|* where ...
2
votes
0answers
36 views

Adding pre built create-react-app to D8 block [closed]

this is my first question here!, so strap on in as this will be good! I want to know how to add a pre "built" react app to a block, created with `npx create-react-app reasons are i want to use a ...
0
votes
1answer
28 views

How can I render an HTML table in a block?

i have created a module for showing third party API data here is some data returned from that API {"ObjectId":43,"ObjectName":"MEGA MELA","ObjectTitle":"Event Created by API","ObjectDescription":"...
0
votes
2answers
33 views

How to get and display menu items except the parent item?

Let's say my menu tree is like below: Parent Sub-Parent Child I want to get the Sub-Parent title and all child's title and url. How can I do it in Drupal 8? I have looked at this answer but it ...
1
vote
1answer
36 views

How do I force Twig output from my custom module, instead of from the theme? [closed]

I'm new to Drupal, I create a module including block and twig. I want to call out my twig(modules/custom/footer_block/src/templates) and store data in there when execute build() in block. However, it ...
0
votes
1answer
38 views

Display Themed 'username' in Block

I am trying to display the themed username in a custom block. MyCustomBlock.php: public function build() { $usersData = \Drupal::service('user.data')->get('my_module'); $usersFromQuery = [];...
0
votes
0answers
31 views

Pass values from a block to a text field (in simplenews subscription block)

I am using the subscription block of the simplenews module, in a custom module through a hook i added a new text field to the simplenews configuration block. My intention is to be able to add a custom ...
0
votes
0answers
5 views

multiple view block by term that list node title tagged with child term

I want to display a view where multiple block are specific to first level term of a vocabulary and that it list all the node tagged with all the child term of that term with deep. I could create each ...
0
votes
0answers
15 views

Getting 403 Error with Slick and Flexslider

Can't seem to figure this one out! First, I tried Flexslider and then I tried Slick. I am getting the same errors (except different but corresponding files associated with each) with both. HTTP403: ...
0
votes
2answers
64 views

Print a view inside a block

In Drupal 7, I use the following code to print more than one view inside a block. <?php print views_embed_view('view_name', 'display_name'); ?> In Drupal 8, it doesn't work and it returns ...
3
votes
2answers
179 views

Delete a block of all layouts

I am using Layout Builder (Drupal 8.7.1) I have a block in several Layouts. How can I programmatically remove all instances of this block and update all layouts without the message "This block is ...
0
votes
1answer
16 views

D7 block view to only show child nodes based on taxonomy

Using Drupal 7 I have a hierarchical taxonomy each node in the site is assigned a taxonomy to identify where it sits in the site structure. On certain pages (landing pages) I would like to show the ...
0
votes
1answer
26 views

Editing CSS without module/plugin

I am working on a website developed by a previous developer so I am studying how I can edit the style without source code or any extension... is there any possibility to do it?
0
votes
1answer
31 views

How to get the list of blocks for the current page?

I'm trying to get the list of all blocks for a certain page, but I can't figure how to do that. How do I get the list of all the blocks that are rendered for a page, independently from the region ...
0
votes
0answers
59 views

Twig and CSS for custom Block not working

I'm working on a custom module that has a block. This block has a form in configuration where user input the relative data, so far it works its saving the data and it display it but without a template ...
1
vote
1answer
26 views

How to render image uploaded from a configuration form

I'm working on a custom module, that contains a block and I'm currently having an issue to render an image that is being uploaded through a form at the configuration of the block. I'm getting this ...
0
votes
1answer
34 views

Output data of different content types in same page

I have two content types : Content type 1 named book with two fields author and language Content type 2 named movie with two fields date and resolution In my-theme/templates/page.html.twig I want to ...
-1
votes
2answers
48 views

Can't edit block

I´m new with Drupal. I started a month ago with Drupal 8. Everything works fine. I had some own custom blocks. Then I added some javascript to one block. Immediately after that editing of the block ...
0
votes
1answer
33 views

How do I convert "entity:node/9 in a link?

I need to get some values from a custom block I've created, and I am using the following code. // Get the block $block = \Drupal\block\Entity\Block::load('hightlight'); // Get the block content $...
1
vote
1answer
16 views

Display a view block with a list of content excluding the one currently displayed on the page

I sometimes use contextual filters to display fields matching the content ID from url In that case , i would like to display a list of content as a view block , except the one that is displayed It ...
0
votes
1answer
21 views

Programmatically added block doesn't appear in block admin page

First of all, this is not a duplicate of this question, as I can't see my block even though I click Place Block. Below is my block class. To the best of my knowledge, it should appear in the list, ...
0
votes
1answer
56 views

How to chart data stored in a database table (dynamically) in Drupal 8?

I found these instructions for using the Charts module to display data from a database for Drupal 7: https://www.drupal.org/docs/8/modules/charts/charts-howtos/chart-some-data-stored-in-a-database-...
1
vote
0answers
54 views

Trouble Hiding Regions When Blocks Are Empty

Having trouble seeing why my regions render when I think they shouldn't... page.html.twig: {% if page.region %} {{ page.region }} {% endif %} region.html.twig: {% if content %} <div id="" ...
0
votes
0answers
78 views

Can't place a custom block

After adding a block file to src/Plugin/Block I can't add the block on the Block Layout admin page. When I filter by block name I can see it, but then when I try to place it I can't get to the ...
0
votes
0answers
40 views

How to set visibility configurations and third party setting in the block programmatically?

/** * Create Custom solutions blocks for Super Category and Category Pages. */ function custom_blocks_update_8008() { $values = [ 'uuid' => '7760fb2f-5235-4390-a91b-32568da6b001', '...
0
votes
1answer
23 views

How to get the View Object from ViewsBlock?

I'm loading a variable list of blocks. In some cases these blocks are a views_block type. When I load a views_block, the viewsblockbase provides the protected View object, but does not provide a ...
0
votes
1answer
43 views

Editing contents of custom block referenced in paragraph type, doesn't reflect changes in node where displayed

So, I have a Custom Block type, let's call it Sidebar Links Block. In an Article, we have a Sidebar paragraph type that allows quite a few different entities, one of which is the Article Sidebar Links ...
2
votes
0answers
78 views

Contextual links in block disabled when using Twig Tweak and UUID

In my taxonomy-term--NAME.html.twig I use a reference field to load a 'block_content'. {% for item in term.field_blocks %} {% set uuid = item.entity.uuid.value %} {{ drupal_block('block_content:'...
0
votes
0answers
11 views

Can I make a “type” available as a block?

I am trying to rebuild my links site in Drupal 8. In Drupal 7, I use a three-column panel page. I use a type to create the categories and with the node-block module I create the blocks. In Drupal 8, ...
2
votes
0answers
21 views

How do I access attributes from within a block?

So I'm calling a block within a HTML container in Drupal 7.x with a shortcode. There is an option for a Dynamic Shortcode as well but alas there is no documentation in the code base. [block admin_url ...
0
votes
0answers
29 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
24 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
40 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
38 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
26 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
67 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. ...