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

Custom HTML / CSS Block OR import

For a given Drupal installation, how could one go about either 1.Copying and pasting HTML code to a block (while accurately specifying its required CSS). or Adding REAL RAW HTML5 code of EVERY kind ...
1
vote
1answer
58 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
9 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
24 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
27 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
27 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
45 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
47 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
53 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
30 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
32 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
16 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
56 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
28 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
47 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
23 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
34 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
7 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
31 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
26 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
36 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
13 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
21 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
17 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 ...
0
votes
0answers
50 views

Block not showing in controller generated tables Drupal 8

I have created a custom module that should show my custom block above the controller generated table. The block shows in other pages but not in the page where it is supposed to show. Found out that it ...
0
votes
1answer
29 views

Block not showing input fields

I have a block as part of my custom module, I was it to show 2 text boxes (Input & Output) and have a generate button. I cant get it to show the input boxes! It seems they are being stripped out ...
0
votes
1answer
25 views

Place a custom block inside admin area

How is it possible to place a custom block inside the admin area? (e.g. in a node edit form)? I tried with page restriction but with no success. How can I see the block regions of the admin theme (...
0
votes
1answer
27 views

BlockContent::load for addtoany_block returns null

I am trying to load the "AddToAny Buttons" block of AddToAny module inside a controller. My idea is to render the block content as a part of the page. I have verified the block id of "AddToAny Buttons"...
0
votes
0answers
14 views

WebDriverTestBase can't place/see block configuration in an AJAX text

I am writing a functional test that checks the output of a page when a user has a specific cookie. Based on that cookie, I have a block powered by Ajax Block that injects block content personalized ...
2
votes
1answer
138 views

Load a block contents dynamically / via AJAX?

I need to have a custom block on the page (will be sitewide) that has two states - one for when a cookie is present and has a certain value, and the other for when that cookie is not there or the ...
2
votes
1answer
38 views

Is accessing the current node from multiple block plugins on a single page costly from a performance perspective?

I use a combination of Block plugins and panels to populate the layouts of the display modes of various content types. Here's an example: class MyBlockPlugin extends BlockBase { /** * {@...
0
votes
0answers
21 views

Issues removing a Block from content

I'm working on an old D7 site and have been asked to remove a Block from a particular page. First thing I tried was to go to the page in question, click the gear icon next to the block and select ...
0
votes
0answers
41 views

Views paragraph fields in block Twig template

I understand that I can use content['#view'].field['field_name'].value(rowcount) to get a value of a field. But how can I refer to fields of a paragraph field, that is in a view block in a file like "...
0
votes
1answer
118 views

DrupalSettings are not passing the values from block to js?

I have been trying to pass the variables from block to jquery. In Block.php, return [ '#theme' => 'block--exampleblock', '#value' => 'test', '#attached' => [ '...
0
votes
0answers
43 views

Display block when boolean field is checked

I currently have a custom block (created programmatically) thats displays on my news content type (via Layout builder). The code I used for block is below. class NewsButton extends BlockBase { /**...
0
votes
0answers
18 views

Getting a book tree/menu programatically

Given a node ID, how do I display the outline of the book it belongs to? I'm dispatching the pages of the book from a custom, variable, route (and not the alias of the node) so the default book ...
2
votes
1answer
59 views

Have followed instructions to disable cache for development but it's still caching

I have followed all the instructions here https://www.drupal.org/node/2598914 I'm developing a module with a block, and when I went to the Block Layout page and clicked "Place Block", the list of ...
1
vote
1answer
33 views

Remove Log in or Register to post comments

For some reason any time a new post is made at the top of the post a module shows up saying Log In or Register to post comments The problem is that it shows up way at the top of the post, instead of ...
-4
votes
1answer
36 views

Block with Listing of custom links to redirect to pages

With Drupal 8 I want to have a block with a select list that I get programmatically from taxonomy terms and when the user clicks on Submit it redirects the user to the page I put in the list. What is ...