Latest Drupal related questions

Score: 0
Matoeil avatar
Pass current langage to twig on custom blocks
za flag

my custom module block, with supposely no cache

<?php

namespace Drupal\amu_social_icon\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'Icon' Block
 *
 * @Block(
 *   id = "amu_social_icon_block",
 *   admin_label = @Translation("Social Icon block"),
 * )
 */
class IconBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $config = \Drupal: ...
Score: 1
Hide Admin Toolbar in iFrame
cn flag

Is it somehow possible within Drupal 8 to hide the Admin Toolbar when the site is loaded within an iFrame? Like e.g. passing an argument? :-)

I thought about using some sort of preprocess on the page that is getting rendered within the iFrame, but this will not work since the html is cached by Drupal. Also I thought about doing it within Javascript, but I do not want to include a javascript file  ...

Score: 0
Greenhorn avatar
How to generate cropped image on upload with Image Widget Crop module?
us flag

When I upload the image it only crops it with the preset size in style if there is, but not with the manual crop in form.

I tried Image Style Warm module, with that the manual crop gets applied when I re-edit the image. Without Image Style Warm module the file only created on image url call.

I also tried to modify the module weight by changing Crop API and Image Widget Crop modules to -10 but it als ...

Score: 3
How to setup access dependency on a block content created programatically
ng flag

In Drupal 8, I am creating block instances (BlockContent) for node layouts programatically and setting them all as non-reusable. That causes a following access error: "Non-reusable blocks must set an access dependency".

How do I set access dependency on an existing block instance (or during it's creation)? Was never in a position to have to manipulate access from such angle and I can't find a goo ...

Score: -1
universaldenker.org avatar
After upgrade to Drupal 9.2: Call to undefined function escapeshellcmd(). Why?
kp flag

When I want to submit a form (webform module) I get get the followng error:

Call to undefined function Drupal\Core\Mail\Plugin\Mail\escapeshellcmd() in Drupal\Core\Mail\Plugin\Mail\PhpMail::_isShellSafe() (line 165 of core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php).

This error disappears if I remove all mails in "/admin/structure/webform/manage/MY-FORM/handlers".

This error occurs also using s ...

Score: 1
How to load a JS library (in a custom module) from a theme using only JS?
ph flag

I want custom subthemes, one for admin and one for front end. both need to load the leaflet js library that im trying to put into a custom module.

Ive got the subtheme bit working, and my global-scripts js running, but cant get module loaded or running.

themes/angas_admin/

angas_admin.info.yml

# subtheme by haydent httech.com.au
name:  Angas Admin
type: theme
description: 'seven subtheme by hayden - h ...
Score: 0
Thirsty Six avatar
How can I programmatically check if a view's result is not empty?
gs flag

Programmatically, How to check if view result is not empty with in custom function? I want to check the views result is it empty or not, and then display the result. How can i do?

use Drupal\views\Views;
use Drupal\views\ViewExecutable;

$view = Views::getView($view_name = "My View");
$view->setTitle('Sample Title');
$view->setArguments($args = ['all']);
$view->display_handler->setOptio ...
Score: -1
Balwant Singh avatar
Change Block view using custom Views
au flag

I have one content type(Contains Image & body field). for that, I have created a custom block view using Views. currently, it's showing content like on the left side the image is placed and on the right side, the body content is placed. I have added content 4 times for that content type. now I want to show that content like:

    LEFT           RIGHT

    image          body
    body           i ...
Score: 0
Extect avatar
How to update a module in production?
cn flag

I am using git to deploy my composer.lock to production. Contrib is not part of my git repo. Therefore, in production I then run composer install to add contrib to production.

What happens when I update a module in dev via composer update, then deploy the updated composer.lock to production and run composer install there? Will it update/replace the existing module code or what is the best practice ...

Score: 1
Why do I get a 403 response code when submitting changes at /admin/people/permissions?
de flag

I have documented the warnings and notices I get in the drupal watchdog logs at this link:

https://gist.github.com/hesco/1797208819f7b239d8be9deca6b8bac4

I see nothing in apache2 error logs.

I see a WSOD with the message: Not allowed. in the browser.
I see the 403 code in the browser inspect tool's js concole.
I also see that 403 in the apache2 access logs for every: POST /admin/people/permission ...

Score: 0
Views query plugin Undefined Index error
ua flag
mfv

I have been trying to build a custom views query plugin but Im getting an undefined index error for each field that i'm mapping. The filters im using for the endpoint do work when i check them. This plugin pulls data from an another drupal site through a json endpoint. I am mapping the fields to views with hook_views_data():

<?php
/**
 * Implements hook_views_data().
 */
function letter_query_vi ...
Score: 1
hga77 avatar
Somehow subscribe/react to addMessage
cn flag

I'm trying to find an event that I can subscribe to for the method addMessage.

I need to trigger some code everytime a status message is added. On reacting to this event, I need to send a variable from php to JS. I could not find an event to subscribe to so instead I used a preprocess, below.

<?php
function mymodule_preprocess_status_messages(&$variables) {
  $variables['#attached']['drupalSettin ...
Score: 1
Jed_BH avatar
How to load a file entity by uuid?
us flag

So I am trying to use the default image for users in a menu block if a custom one does not exist. And for it I am getting the image file uuid:

$default_image = $user->get('user_picture')->getSetting('default_image');

Then loading the file entity:

$file = Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid']);

This is returning null. What am I doing wrong? And ...

Score: 3
Vivank Sharma avatar
How to get Automation testing results of Drupal contributed module through Drupal.org rest API?
lb flag

I am trying to get automated testing results of contributed modules through https://www.drupal.org/drupalorg/docs/apis/rest-and-other-apis.

I am able to get nid and vid of any contributed module through the node info API.

And I want to access DrupalCI jobs: pift_ci_job.json or pift_ci_job.xml

Which returns a specific job: https://www.drupal.org/api-d7/pift_ci_job/[jobid].json

But, there is nowhere men ...

Score: 0
Shawn avatar
Javascript, saving a event state?
cn flag

So I have a table that has about 10 items listed. When I click on a 'TR', in my javascript code, I have it set where it highlights that particular table row green. This is basically a generated grocery list and as you browse through the store, you basically "check off" your items that you have picked up.

However, me and my wife both use this since I put it on a live site and I was wondering, how  ...

Score: 0
How can we build a view of nodes with their redirect source URLs shown in it?
id flag

I want to build a view of nodes with their redirect source URLs along with node titles. However a direct relationship cannot be established as they do not have a common reference.

The Stunning Power of Questions

Much of an executive’s workday is spent asking others for information—requesting status updates from a team leader, for example, or questioning a counterpart in a tense negotiation. Yet unlike professionals such as litigators, journalists, and doctors, who are taught how to ask questions as an essential part of their training, few executives think of questioning as a skill that can be honed—or consider how their own answers to questions could make conversations more productive.

That’s a missed opportunity. Questioning is a uniquely powerful tool for unlocking value in organizations: It spurs learning and the exchange of ideas, it fuels innovation and performance improvement, it builds rapport and trust among team members. And it can mitigate business risk by uncovering unforeseen pitfalls and hazards.

For some people, questioning comes easily. Their natural inquisitiveness, emotional intelligence, and ability to read people put the ideal question on the tip of their tongue. But most of us don’t ask enough questions, nor do we pose our inquiries in an optimal way.

The good news is that by asking questions, we naturally improve our emotional intelligence, which in turn makes us better questioners—a virtuous cycle. In this article, we draw on insights from behavioral science research to explore how the way we frame questions and choose to answer our counterparts can influence the outcome of conversations. We offer guidance for choosing the best type, tone, sequence, and framing of questions and for deciding what and how much information to share to reap the most benefit from our interactions, not just for ourselves but for our organizations.