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
0answers
11 views

Mail ahref in a block

I have created a custom block in Drupal8, and it prints the HTML correctly into the template. However, I am sure that Drupal8 Core is striping mail out of this part of the link href="mail:' . $email . ...
1
vote
2answers
32 views

How to show a block between the body and a paragraphs field?

For a larger article content type on a Drupal 8 page, I want to have the following structure: Title Image/Video Body (the normal node body with the title and some text) A contanct block Paragraphs ...
4
votes
2answers
149 views

What is the correct way to update my cached block when a node of a given type is saved or updated?

I have a custom module with a block plugin: SliderBlock.php class SliderBlock extends BlockBase { public function build() { $build = []; $build['#theme'] = 'slider_block'; return $...
2
votes
1answer
43 views

How to get total number of rows on a block of a view

On hook_block_view_alter() I need to get a total number of rows that this block displays. For example, I have a view with the following block: On hook_block_view_alter() I do the appropriate checks ...
0
votes
1answer
66 views

Cache a block by a custom entity rendered within

I struggle with getting a custom block cached correctly: we have a custom entity "Politician" For that entity we have several routes where we want to render a "politician header" with some basic ...
1
vote
0answers
6 views

How do I add an item to the Bootstrap Simple Carousel on Drupal 8?

I'm having problems configuring the Bootstrap Simple Carousel module on Drupal 8. I see that I can add carousel items at /admin/structure/bootstrap_simple_carousel and I've created the carousel block ...
1
vote
2answers
30 views

How to get a machine name of a custom block

I have a custom "Slider Items" field type, as well as the custom "Channel Slider Block Type" type block (created using "Custom block library"). Also, I have several "Channel Slider Block Type" blocks....
0
votes
1answer
19 views

Consume external API from custom block

I am currently writing a custom module - block plugin for Drupal 8 - How do i go about consuming/sending external API data and displaying them using blocks? Is this the standard way - consume/send ...
0
votes
0answers
32 views

How can I print just one field of a view in a block template? [duplicate]

I created a view block that is "more by this author" and was able to configure the view so that it pulls the author of the current node and shows more pieces of content by that author. Hurray! I ...
0
votes
0answers
6 views

Adding a new field to the layout_builder_update_block/layout_builder_add_block for a view block for usage later

We are using layout builder for adding view blocks to node pages. I need to modify the "add/update" form with a new boolean field (checkbox), and use the results that are stored (true/false) later on ...
0
votes
1answer
61 views

How can I get the currently submitted form state in a block on the same page?

How can I retrieve the currently submitted and validated form state? Please assume the following scenario. A page has a form on it created using the form API. The data in the submitted form is ...
1
vote
0answers
12 views

Only show view/block on nodes with certain field value when using “Content: Has taxonomy term ID”

I've set up a view of related content that has a block display and 2 contextual filters: "Content: ID" with "Exclude" "Content: Has taxonomy term ID" with "Load default filter from node page, that's ...
0
votes
1answer
52 views

Creating a block type programmatically

I want to create a block type that has a couple of fields, a template and attached js. I want that the user in my site will be able to create blocks of this type just like they create a custom block :...
0
votes
0answers
20 views

How to render blocks based on a view result?

I have this views page which acts as a search result page for search API with SOLR. And to improve it I added facet and sort blocks. It works alright, except that when the search doesn't return ...
0
votes
0answers
21 views

Sharing permission in controller and block

I have a custom block on and entity page that displays buttons that when clicked send an AJAX request to a custom controller. A button in the custom block is displayed if a certain condition is met (...
0
votes
0answers
25 views

Custom block admin page

I'm trying to build a module to create a custom admin page to manage a custom block. I would like to include the block content field and a checkbox to enable or disable the block. Is this possible or ...
1
vote
1answer
75 views

Problem setting user specific cache tags on custom block with user context

I have a simple custom block with a user cache context and a specific user specific cache tag: /** * Provides a 'User example' block. * * @Block( * id = "user_example_block", * admin_label = ...
0
votes
0answers
10 views

Creating search form that will query SQL database and display results on a custom block

I am new to Drupal and have learnt about custom blocks. Basically, I am trying to create a search page where on the left column will have all the filter/search criteria. On the right column the ...
0
votes
0answers
27 views

Drupal 7 WYSIWYG module with CKeditor library stripping form and input HTML tags when inserted into a block

I'm wanting to add some code snippets from MailChimp. We are using the WYSIWYG module (7.x-2.5) with the CKeditor library version (4.9.2.9). When I add the code to a block it is stripping out when ...
0
votes
1answer
37 views

Template preview not working properly

I've got a huge problem with my template preview. For all of my post (page, article and so on), I have not the good region in my page. My theme is extended Classy. If I go to see the page (not ...
0
votes
0answers
10 views

Set block content from panels / page manager?

I am configuring a panels page manager page which also should have a specific sidebar block (search filters related to the page content). I want to use the regular page.tpl.php where the sidebar is a ...
0
votes
1answer
28 views

Navigate to page with content displays page not found error

I have a URL (/url1) that I navigate to that is showing content because of the Context module. The Context module has a condition that when the user navigates to /url1, some view blocks are rendered ...
0
votes
0answers
17 views

Seach Page Split into Form Block & Results Block

I already created a search view like /search it is giving form and results finely but Views UI is disabled in my server . So i want to split this search page into 1) A block which contains a search ...
3
votes
1answer
46 views

How can I programmatically distinguish if a block is enabled or disabled from block layout?

I have 2 custom blocks. I have added both this in regions of block layout. But when i disabled the block from layout. I must identify it from code or api that the particular block is disabled. How to ...
1
vote
1answer
51 views

Create a custom blocks visibility tab (show on certain domain only)

I want to show a block only on a certain domain. I know I can use the domain access module for this but this looks like a to heavy module for my use case. How can a create a custom visibility tab for ...
5
votes
1answer
55 views

How to determine if a View display is being used in a site?

We have many Views and Views displays. Over 3 years of building the site we have many displays that are not being used. We would like to delete them and clean up the view but are concerned that a ...
0
votes
1answer
31 views

Alter block form

I'm using the contrib module contact block and I would like to edit the block form settings. By default, there is a textfield (title) and the "Display title" checkbox, I need to hide those fields by ...
1
vote
1answer
37 views

How do I include a twig file in a custom block type module?

I've created a custom module that creates a jumbotron custom block type. The module has an empty .module file and a dir config/install with many .yml files. This works great when I install and create ...
0
votes
0answers
33 views

Make field required if entity reference field is filled

I'm trying to make some fields required if an entity reference field is filled. This is the code I currently have: $form['node'] = [ '#type' => 'entity_autocomplete', '#title' => $this->...
0
votes
1answer
34 views

How can we check whether block is enabled or disabled in .theme file?

I am displaying a block in twig and i am passing twig variable from hook_preprocess_page. But the issue when i disable the block from backend still its showing up in frontend. Im not able to get ...
0
votes
1answer
19 views

How to move block from a region inside of hook_preprocess_node?

I have added mycustomblock to the header region in our settings (/admin/structure/block). We are using the standard content block and displaying that in the Content region, which is displayed below ...
0
votes
1answer
46 views

How do I print individuals fields in block.html.twig when is a node in a block?

How do I print individuals fields in block.html.twig when is a node in a block? The template is working fine. I can hard code some random text and it is displayed. I just can't display the field ...
1
vote
1answer
90 views

How can I display the block title when rendering a block using Twig Tweak?

Block title when using twig-tweak plugin, not showing. I created a block-type view. And using the module's cheat sheets, I called: {{ drupal_view('views_name', 'block_1') }}
1
vote
1answer
29 views

How do I know when another contributed module deletes a block?

I have written a Drupal 7 module that adds about ten fields to the block administration configuration form and saves the values for those fields in its own database table. My module does not create ...
0
votes
0answers
54 views

How to display values of certain taxonomy term above the table with the search results list based on content type, related to entering search query?

I made a view which displays a search result list as a table. The searching process works inside one content type using Search API. The system also has to look for between taxonomy terms (name) first ...
0
votes
0answers
49 views

Drupal 8 block cached, but the expensive call still runs

So I created a custom block like this: public function build() { $output = [ '#cache' => [ 'keys' => ['bix_salary_jobs'], 'contexts' => ['url.path'], '...
0
votes
0answers
39 views

Ignore custom block field content (settings) with config_ignore

I am trying to ignore the content of some fields in a custom defined block plugin. In my block plugin (class MyAwesomeBlock extends BlockBase implements BlockPluginInterface { ... }) I've declared ...
0
votes
0answers
23 views

Is it possible to auto-translate a block?

I am hosting a Drupal 7 site and require some quick translations. I have found how to set up some auto-translations which I can then modify for all the content types (articles, basic pages, etc), but ...
0
votes
1answer
26 views

Check access to existing plugin block

I have a programmatical plugin block defined in theme region. I need to check access to this block in my module hook. The following code creates a new instance, but I need to load an existing plugin ...
2
votes
0answers
35 views

Any downside when using block_content as custom content entities?

Background: For a tourism project I need to integrate volatile data from external sources (like snow reports for ski ressorts or movies and their showtimes). This data should not be accessible by its ...
0
votes
1answer
8 views

View block filter by taxonomy term (field)

I am doing some block experiments because I'm new in Drupal and I want to know if I can create a view block to place X(more than one) times in the same page with different results by taxonomy term ...
0
votes
0answers
25 views

How to display Block content only to users that have submitted a specific webform

Background: Our Drupal website has different user types, lets say A, B, C, D, and E. We have private content that should only be accessed by A, B and C once they agree to the privacy terms, which are ...
1
vote
1answer
32 views

Add textfield to system branding block form to specify link URL

I would like to alter the branding block to add a textfield in the block form to specify the URL it should redirect to. The URL is currently fixed to <front> in the Twig template. What I've ...
0
votes
1answer
20 views

Drupal 8 - Add custom HTML with script to embed on a page as block

I need to add a custom form that has scripts and styles into a page as a block. Its dynamic, so I couldn't attach the scripts (#attached) as libraries. I just need to place the contents as is. $...
1
vote
1answer
27 views

How to modify the D7 user login page html to remove the register and new password options for non-admins?

So, I'm maintaining a Drupal 7 site for which we recently switched the users over to SSO through a third-party OAuth provider. The implementation isn't fancy, but added a login link to what I assume ...
0
votes
0answers
21 views

Default CSS classes for custom block

I've defined a custom block (Drupal 8) and I'm able to specify defaults for block label and my other custom fields but can't figure out how to hook into the 'CSS class(es)' field for defaults that ...
0
votes
1answer
45 views

How do I pass multiple block configurations to a behavior?

I am trying to create a Drupal 8 module that implements a Curator IO widget, so I created a block plugin with its own custom configuration. public function blockForm($form, FormStateInterface $...
0
votes
1answer
14 views

how to have a different page from the front page?

In my site (psa.modares.ac.ir) all my pages are the same as the front page. for example, I have our team block and price table on the front page but I also see them in blog posts or article pages. why ...
0
votes
0answers
22 views

Webform block not display

In D8, In Block Layout, Place Block of webform of webform form, but when we see output display empty. Inspect element display span tag data-big-pipe-placeholder-id="callback=Drupal%5Cblock%...
0
votes
1answer
18 views

Resizing a block on a drupal 7 website

I have three blocks A, B and C on the home page on location Content Bottom. I have another block D I want to place at location A+B and I want to keep C at the same location. I will move A and B to ...