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
20 views

Creating a custom block programmatically in Drupal 8

I followed the steps from https://www.webwash.net/programmatically-create-block-drupal-8/. I have a view already created and I want to render this view in this block. I can't find a good ...
0
votes
0answers
9 views

Custom Block Config - Accepting array of objects

I have built a component following the docs but am wanting to add configure to allow the user to add a series of objects that each contain a 'title' (a text field) and a 'content' (a list of text ...
0
votes
1answer
36 views

How to restrict access to view a block for a certain role?

I have some custom roles such as Premium Membership and I don't want to allow access to this category. The authenticated role is included to Premium Membership or Moderator users because every ...
0
votes
0answers
33 views

Is a block render array built with EntityViewBuilderInterface::view supposed to render full block template or only inner fields?

After rendering custom blocks in templates, I got this js error: Quick Edit could not associate the rendered entity field markup. What I've done so far : In order to render repeatedly custom blocks ...
0
votes
1answer
29 views

Sub-theme adding prefix to all block machine names

On my site, I have created a sub-theme of a sub-theme using this as a guide to set this up https://www.drupal.org/docs/8/theming-drupal-8/creating-a-drupal-8-sub-theme-or-sub-theme-of-sub-theme and it ...
0
votes
0answers
11 views

Contextual filter for month and day

I have created a block that lists all the users () that are years old that same day. The problem is that when I want to add a contextual filter that compares the birth_date field with the current ...
0
votes
1answer
21 views

Drupal 8 Accessing Menu Tree in a Block's JS

How can I pass the menu into a block's javascript? I am trying to build a block for a custom mobile menu (client wants specific logic/animations/etc) and use that in Structure > Block layout > Main ...
-1
votes
0answers
25 views

Need some guidelines for working on Drupal theming [closed]

Drupal version: 8.8.2 Hello fellow Drupal devs, I am new to drupal, but have good experience in PHP. Website is related to tiles. I am trying to do a project-specific custom theme. Having some ...
-3
votes
0answers
17 views

Best way to create custom page with statistics [closed]

I would like to create some statistics: total number of registered users, total number of subscribers, total number of registered users online on website without paid membership and so on. I'm trying ...
-1
votes
0answers
25 views

How to embed Vimeo video on Drupal 7 block body?

Embedding a youtube video is super easy like: [youtube:23km5H4K9Eo5] inside the block body with full html. Is it the same format with vimeo? [vimeo:GD34fsAf53], because that doesn't load for me. Sorry ...
1
vote
1answer
21 views

Splitting exposed form filters amongst several blocks

I have a views search page in D8 where I'm I have exposed filters that are shown in blocks. I'm also using search facet blocks. What I want in the sidebar is the exposed filter text search field, ...
0
votes
0answers
10 views

Sort tags in a view by the number of content they are displayed in

I'm trying to make a view that would display only name of tags and the number of content that uses that tag. I have managed to do this following this tutorial: https://www.youtube.com/watch?v=...
0
votes
1answer
17 views

In node add, how to upload file using image from clipboard

How can I paste image from clipboard and save into image_field ?
0
votes
0answers
17 views

How to disable “Tampering rejected … An attempt to update the title of node…”

I write a code to change the node's title after the form is created, but it always says Tampering rejected ... An attempt to update the title of node with ID "42154" was discovered (from "9-2" to "...
0
votes
0answers
38 views

How do I control which tabs a block is displayed in?

Drupal 8.8.1 with commerce 2 installed. Goal is to make better use of the ‘logged-in user’ landing page(My Account) by adding blocks of useful content. Blocks created using the UI as well as coded ...
0
votes
0answers
17 views

How can I generate custom block types for site testing?

Devel generate is great for testing a site and theming without content in place. It doesn't seem to support custom block types. Is there something similar available for these or a patch?
0
votes
0answers
29 views

Custom link in views block

In Drupal 7, I used the Views Panes More Link module to customize the text of the "More" link. I need to do the same thing in Drupal 8. I am using panels but I am open to other soulutions. I have ...
1
vote
0answers
34 views

Render blocks of custom type

Either I'm stupid or I can't search. Sorry if this is a duplicate, but I can't find any answer to my problem. I made a custom block type in admin panel, named it content_under_listing, and then I made ...
0
votes
0answers
16 views

Get data from one editor field and pass that into another editor field

I have no idea if this is even possible, but I figured I'd ask anyway. I'm working with a site that is on Drupal 8, and long story short, we don't have access to extending nor updating much so any ...
0
votes
0answers
18 views

Allow off-canvas dialog to be rendered on the left of the page in Drupal 8

this is my current code to display a custom block off-canvas. $build['link'] = [ '#title' => 'Select Sources', '#type' => 'link', '#url' => Url::fromRoute('heritage_ui.sourcesmenu', ['...
0
votes
0answers
27 views

How to access the block ID in hook_block_view_alter()?

How can I access the block ID in hook_block_view_alter()? function mysite_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) { if ('my-block-id' == $block->...
0
votes
1answer
35 views

Why doesn't hook_preprocess_block() alter the block content?

I'm finding I can't alter block content with hook_preprocess_block() in Drupal 8. Should I expect to be able to alter content, such as a block body, using hook_preprocess_block()? For example, this ...
0
votes
0answers
13 views

Content corrupting when reverting a revision

Our website is powered by Drupal 7 and have a bootstrap based rotating carousel on the home page, which has a link on each slide to a different page. This is powered by the Bootstrap Carousel module (...
0
votes
0answers
17 views

Using a computed field in a view for a specific content type

I have a computed field (entity reference) that is auto-generating a date in a specific Issue type format (Month/Month Year) for the Article content type. I have a datetime field (date_field) in a ...
1
vote
1answer
51 views

{{ drupal_view('view1', 'block_2') }} renders only when cache is cleared

I like to output 2 block-views in a template called "block--bar.html.twig", but only when i clear the cache they are printed. (i installed Twig Tweak 8.x-2.x) This is the template: <section{{ ...
0
votes
1answer
20 views

login form generated by drupal_get_form('user_login_block') does not log in

I have a custom module part of which builds a block with the login form function my_module_block_view($delta = '') { switch ($delta) { case 'awsImage_public_info_forms': $user_login = ...
0
votes
1answer
28 views

Composite block from multiple other blocks + layout

I would like to create a block consisting of multiple other blocks, combined with a layout or some other kind of wrapper html. A typical example would be a footer with 4 columns containing a menu, ...
1
vote
2answers
42 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
161 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
57 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
73 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
9 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
32 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
28 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
35 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
8 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
68 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
18 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
78 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
23 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
136 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
23 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
29 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
53 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
12 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
47 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
2 3 4 5
55