Stack Exchange Network

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

-1
votes
1answer
32 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
20 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 ...
-1
votes
0answers
16 views

Contextual filter in Block

I have created a content type product-review and added a field that is a reference field of taxonomy. Created a view to display all product-review contents. Created a block in the same view to display ...
0
votes
1answer
9 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
25 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
38 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
0answers
9 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
29 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 ...
-3
votes
0answers
24 views

Creating a content of a content type using block [duplicate]

I have a content type of job posting in which users can post jobs. The page is having anonymous access also. (/node/add/job_posting with url alias /job-posting). Now I need this page as a block ...
0
votes
1answer
40 views

Restrict block visibility by page url

Can I restrict the block visibility only show for /worker/*/ but not /worker/*/...?
0
votes
1answer
28 views

Block with form input serving other blocks data

I have a custom module which had a form with some inputs and after submitting it, it creates two tables with some info. I'm now changing the way I show the information. For that, I'm using Panels, ...
0
votes
2answers
46 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
26 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
19 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
23 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 ...
-2
votes
0answers
18 views

Display Block After some time using ajax?

I have alter the webform block after some times to display in page. for example. The Block should be display to the user after the one minute. I have rendered the block in some region and the block ...
1
vote
2answers
46 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
24 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
15 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
51 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?
-1
votes
0answers
26 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 ...
-1
votes
0answers
45 views

Config block translation?

EDIT - Here is my block src code. The module directory has no other files except the .info.yml: namespace Drupal\config_block\Plugin\Block; use Drupal\Core\Block\BlockBase; use Drupal\Core\Block\...
0
votes
1answer
29 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
210 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
132 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
12 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
177 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
16 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 ...
2
votes
1answer
22 views

Display block content in current language

I have multilingual Drupal 8 site. I want to display views block in home page. It should display block contents in current site language. Example: I have content type called "Book". Which has ...
0
votes
1answer
23 views

How do I use a different structure of a theme on different pages?

The picture shows the block region demonstration of a Drupal theme that I am using. I am new to Drupal. As the structure is given, I want to use different structure in different pages of my site. ...
-1
votes
0answers
62 views

Block disappears unless I refresh route and link cache

I have a submenu based on the main navigation menu system. This Plugin Block builds the submenu on every page. The links of course change based on the route. Every hour around the same time, the ...
0
votes
1answer
15 views

Related events block

I have a content type, Venues and a content type Events. In the Events post type, I have 'field_hosted_by' - allowing me to select the relevant venue. On each venue page (/venue/venue-name), i'd ...
0
votes
0answers
40 views

Add class to UL in menu block if block has class

I have a menu that I am display in a menu block. I am using the Block Class module to add a class to my menu block. For example: I have a menu called "About Page Menu" that has 3 menu items. I place ...
0
votes
0answers
32 views

Dynamically set theme per block/paragraph

I'm looking to apply specific themes to individual items on a page - a different theme to the rest of the page. I realise this seems quite obscure, but the general premise is similar to a styleguide. ...
1
vote
0answers
41 views

Same session variable retrieved in different blocks not stable

I have a module that have three blocks. Block No 1 sets the session Block No 2 gets the session Block No 3 remove the session Each block is assigned to a different page. Now, for some reason this ...
0
votes
1answer
54 views

How to render the field from custom block in node.twig

I want to render the custom field from my block in node.twig. As I understand I have to expose the fields from Block to Node variables. How to realize that?
-1
votes
0answers
61 views

Custom Block disappearing periodically even cache max-age is zero [duplicate]

There is a Drupal 8 custom block which is created by extends from BlockBase class in the custom module. To make this custom block uncachable, added below code line before return statement. $build['#...
0
votes
0answers
25 views

How can I duplicate the auto-populating feature of the main navigation?

I'm trying to create a menu that is the same as the main navigation, but has its configuration tracked separately. This is important because there are some menu items on the new menu that I'd like to ...
0
votes
2answers
62 views

Where should I place hook_block_view_alter?

this may be a trivial question, but I have no clue to how to get this working. I have this theme 'nexus'. When try the hook function nexus_preprocess_block(&$variables) in the file nexus.theme,...
0
votes
1answer
27 views

Get raw value of a block content

I have created several views. These views have a block display. If I use these blocks in my template, the views are rendered with all the wrappers / divs. In my block template, can I alter the output ...
1
vote
1answer
37 views

How do I verify a block can be shown in the current page? [duplicate]

I created a normal block and configured it using the following settings. I don't want to show the block on node/2 and node/3, for example. I want to get the block render, but verify first the ...
0
votes
2answers
85 views

Disable block caching

I just made a simlple block by using block > custom block, so I didn't make it programmatically. I am a Drupal 8 newbie, and I look for a simple and clear solution how to disable caching for that ...
0
votes
1answer
53 views

How can I (programmatically) display a custom block with user profile links in dropdown?

I would like to display a custom block with some links for authenticated users like drupal.org does. I would like to display username next to user's picture, and custom menu items. For example, "My ...
1
vote
1answer
25 views

How to render a block provided by a contrib module in a node template

I installed Better Social Sharing Buttons and I can not understand how to programmatically display the block of this module in node.html.twig. I display the blocks created by me like this: function ...
2
votes
1answer
25 views

Is there a way to display primary tabs vertical in separate block?

In Drupal 7 I want to rearrange standart drupal tabs (eg. 'View' and 'Edit') as vertical and move it to sidebar. Is there a way to do this?
0
votes
0answers
10 views

The cutom filter block disappears when new search key is entered

I am using the Search API, I have created a /search page for observing the search results based on three entity types. I have two exposed filter: The "Fulltext Search" filter is located in the ...
0
votes
1answer
17 views

Views block doesn't appear on page if only media-type content is selected

I've created a view block that has a contextual filter with a Content ID from URL. The view is only to appear on my content types if the field_aside_content has any data in it. This field is just a ...
0
votes
0answers
55 views

Overwrite default (Bartik) block.html.twig from my custom block module folder [duplicate]

I have a custom block module. I want to override core/themes/bartik/templates/block.html.twig in my-module directory. In my-module directory I have a folder templates/ and the twig file block--my-...
0
votes
1answer
84 views

how to know block id in class which extend from BlockBase

I am trying to get block id in my custom module in build function of class which extends BlockBase. How can i do this? i want to use this block_id in another class controller to have configuration ...