Latest Drupal related questions

Score: 0
Arto Rovie avatar
How to sum views field value
pe flag

A have Drupal 8 and a custom module, which adds a custom field to a view. I want to sum two fields in each views row.

In my module I sum two field values:

  public function render(ResultRow $values) {

  $value = $this->view->field['field_one']->original_value;
  $value_two = $this->view->field['field_two']->original_value;
  $sum = $value + $value_two;
  return $sum;

}

but I get a num ...

Score: 2
Sarah C avatar
How to verify if a custom logo is used?
za flag

How can I check whether the site is using the default theme logo or a custom logo?

When I use the Twig debug tools to dump the site_logo variable, I only get the path of the logo, which doesn't tell me if that is the default theme logo.

Score: 0
Nested conditions groups in views filter plugin
ni flag

I need to nest some "where Groups" on a QueryPluginBase query, but I can only nest first depth group to the main "where" using setWhereGroup. I need to add groups into another groups but there isn't a function to do it because setWhereGroup let you add a new OR/AND group but I can't set the parent group ID I'd like to nest. For example, I'd need:

((Condition1 OR Condition2) AND ( (Condition3 OR Condici ...
Score: 0
Roma Roma avatar
How can I select multiple rows from a table and let the submission handler know which rows have been selected?
gb flag

In a custom module, I have a form showing a table with multiple rows, as in the screenshot.

screesnhot

Once users select one or more rows, and they click on the Delete button, rows in the database should be deleted.

I've built a tableselect table with type. I cannot understand how to get the selected table rows in the submission handler.

How can I achieve this?

The following is the code I am using to build the for ...

Score: -1
Jiah avatar
Configuration synchronization page throwing 504 timeout error
in flag

This issue is happening on every level above my vagrant local box. It's a brand new website and a few days back I had to copy my database from local to staging environment. Once done, I ran drush -cim to import the files from config/sync directory into the database.

no error while running the drush -cim command and also all the UUIDs match from local to staging environment. However, on loading th ...

Score: 0
kumar saurabh avatar
How do you set the file extension while uploading images through file_save_data?
th flag

I am trying to create a product with a product image on drupal using API. I have created a custom module for the same under which following code to upload my image to the Drupal:

$path = base64_decode($encodedData['content']);
$data= $this->grabImage($path);
$file = file_save_data($data, null, FileSystemInterface::EXISTS_REPLACE);
        
$id = $file->id();

I am using file_save_data drupal meth ...

Score: 0
Checkout pane doesn't display custom panes
cn flag

I'm using the documentation example. For some reason, I cannot get the custom pane to display in the checkout.

What am I missing?

I'm using the latest version of Drupal Commerce and Drupal 9.2.

namespace Drupal\my_checkout_pane\Plugin\Commerce\CheckoutPane;

use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a custom messag ...
Score: 3
Can we add custom CSS class in \Drupal::messenger()->addStatus()?
cn flag

I did some research regarding adding custom CSS classes in the message but could not find the actual solution.

As per Drupal 9 documentation:

\Drupal::messenger()->addMessage(t($message));

public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE);

I don't find the option to add CSS class. On the frontend, I would like to add custom CSS class custom-messages--status in the outp ...

Score: 0
DCCweb avatar
How to have URLs show up as clickable links in Webform submissions sent via Swift Mailer
tr flag

I've got Swift Mailer and Mailsystem installed on a Drupal 8 site I maintain, mostly to handle email submissions from Webforms.

And everything's been working fine — except that just recently we got a Webform submission in which the person had included some URLs in the main message area of the webform (a textarea field). And I was surprised that they did not show up as clickable links in the ema ...

Score: 0
Subsequent migrations take long time to being importing data to destination
cn flag

I've got a pretty large migration set of roughly 200k users. The first time I run the migration (via drush), or after rolling it back and starting again, the rollback+import starts immediately. By this I mean that the progress bar starts showing progress on importing items right away.

I know there's no way around the migration itself taking a long time due to the number of items, but I'm running  ...

Score: 2
How can I prevent a webform submission from being saved?
bm flag

I'm writing a custom WebformHandler and am wondering how I can prevent a submission from being saved? I've tried using the RESULTS_IGNORED and SUBMISSION_OPTIONAL in the @WebformHandler annotation, but the submissions still get saved. Is there an additional step, say in the submitForm() method?

/**
 * Premium Content Webform Handler.
 *
 * This is a custom handler to tie into the premium content form ...
Score: 2
Wingman avatar
Join with Like in Views Plugin
kr flag

Attempting to do a join with a LIKE operand in a Views filter plugin. The query looks similar to below; however, when it executes, the LIKE operand is not taken into account and the join is done with '='. Is there a way to do this type of join?

$configuration = [
     'type' => 'INNER',
     'table' => 'path_alias',
     'field' => 'CONCAT(\'%\', path_alias.path)',
     'left_table' =&gt ...
Score: 0
Rog Boy avatar
get translation programmatically of field value in specific language
ma flag

I have created a content type (pdf_form) to which I added a field_gender_languagetest with two options, male and female. I translated both the options in German using the translation tab.

Now I am generating a report of the data filled by users using that content type.

Is there any way to programmatically get that translation?

I am trying this code, but it doesn't work.

t('male', array(), array('langcod ...
Score: 0
Monster971 avatar
How to make a vertical menu properly?
id flag

Good morning all,

Today I would like to ask a simple question about the menus. How do you make a clean sidebar that takes up the entire length of the page? In general, the themes offer only natively horizontal menus that occupy the entire width.

To have a sidebar, you must put the menu in a block side position and make the necessary adjustments with CSS?

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.