How does Drupal 8 load its modules?

I am trying to find out exactly how and when the custom modules are initialized and loaded in Drupal 8.

Note that I am not trying to discover how to create modules, but I am more interested in the software patterns that are used to extract custom modules.

Compliance with cookies and Google Analytics in Drupal 8

I am using Drupal 8.6.14 (I will update soon) and I am trying to create a cookie consent page that really works. I have used many different modules, such as EU Cookie Compliance, GDPR Compliance and several others, but none of them block Google Analytics cookies. I even used a couple of patches in google analytics that I found in the community to support the EU cookie compliance module, but they all failed. To be exact, EU cookie compliance seems to load cookies normally, then deletes them when the consent dialog box appears and then reloads them once I choose any option. All other solutions do not seem to work at all (I receive cookies every time the page loads). By the way, all the solutions I have found are for <8 versions. Any idea how I can do this? Am I missing something?

How do I retain user input on a form after submission in Drupal 8.x?

I am working on a simple form to search a collection of marriage licenses. It consists of a selection box where the user can choose to look up surnames, names or both, and a text field where he writes the name he is looking for.

Everything works fine so far, except that the user's entry is not retained after submitting the form. For example, if I choose "Last Name" and enter "Olsen", after submitting the form, the search box will be empty and the selection box will return to its default "First and Last Name".

Here is my buildForm() method:

public function buildForm(array $form, FormStateInterface $form_state){
    // The select box.
    $form('target') = (
        '#title' => $this->t('Search'),
        '#type' => 'select',
        '#options' => (
            'both' => $this->t('Both first and last names'),
            'last' => $this->t('Last names'),
            'first' => $this->t('First names'),
        '#default_value' => $form_state->getValue('target'),

    // The search box.
    $form('q') = (
        '#title' => $this->t('for'),
        '#type' => 'textfield',
        '#default_value' => $form_state->getValue('q'),

    $form('actions') = ('#type' => 'actions');

    $form('actions')('submit') = (
        '#type' => 'submit',
        '#value' => $this->t('Go'),

    return $form;

As you can see, I tried using #default_value to set a default value by calling the form status to get what the user chose / entered. But, unfortunately, this does not seem to have done it.

How do I get it to show the user’s entry on the form after submission?

Problem with publishing nodes in Drupal 7

I think this is a problem with the Review module, but I'm not sure. When I publish a node, the image in the body is not displayed … But when I press save, it reappears and returns to normal.

Has anyone experienced this?

Category-based cookie consent – Drupal Answers

I am trying to use the EU Cookie Compliance module (GDPR Compliance).
I want to have separate categories that users can accept / reject and that the javasscripts associated with each category are loaded or not loaded accordingly.

However, this does not work, the module does not add the javascripts that have been allowed to

This is what I tried to do.

There is an "Opt-in with categories. Allow visitors to choose which cookie categories they wish to opt for (compatible with GDPR)". option

But activating / deactivating javascripts based on category consent does not seem to work.

I have configured several categories in the "Cookie categories with separate consent" box as follows

Strictly necessary cookies | tag one | some text
Google Analytics | tag two | some text | some text

I have entered the following in the "Disable JavaScripts" box
Strictly necessary cookies: themes / custom / mytheme / js / tracking / Facebook_Pixel_Code.js
Google Analytics: themes / custom / mytheme / js / tracking / Google_Analytics.js

When I do this, the scripts "Google_Analytics.js" and "Facebook_Pixel_Code.js" are not loaded even if consent is given.

I have used the following javascript to see what you think consent settings are
console.log ("ALL" + Drupal.eu_cookie_compliance.hasAgreed ());
console.log ("Strictly necessary cookies" + Drupal.eu_cookie_compliance.hasAgreed (& # 39; Strictly necessary cookies & # 39;));
console.log ("Google Analytics" + Drupal.eu_cookie_compliance.hasAgreed (& # 39; Google Analytics & # 39;));
console.log ("Category not existing" + Drupal.eu_cookie_compliance.hasAgreed (& # 39; Category not existing & # 39;));

"Strictly necessary cookies" and "Google Analytics" always show the correct configuration for consent with respect to those categories.
The "Non-existent Category" is just a test that I used to make sure that JavaScript does what I hope it does (the non-existing Category must always be false)

Interestingly, I have noticed that the initial consent for ALL begins as false (what it is supposed to be), but when the "Save preferences" button is used, the consent for ALL is fulfilled even if a single category was not chosen. I have also noticed that if I add a javascript to the "Disable JavaScripts" box without putting a category in front (ie themes / custom / mytheme / js / tracking / Facebook_Pixel_Code.js), the javascript listed is loaded every time ALL consent is set in truth, as it is supposed to be, it is only the consent configuration based on the consent that does not load / stop the javascripts correctly.

Did I configure it correctly or is it likely to be a mistake?

topics: print the custom user field on page.html.twig Drupal 8

I created a couple of fields for the user in Drupal 8, for example: name. And I'm trying to print it on the home page (page.html.twig) but it was in vain.
I tried the following:

{{ user.field_first_name.0('#context')('value') }}
{{ user.field_first_name.0.value }}                     
{{ user.field_first_name }} 

I even tried adding preprocess functions in mytheme.theme, and it still didn't work.

pointing out that the following works

{{ user.displayname }}

I appreciate any help provided,

Thank you

database: Emoji works in drupal site 8 but not in drupal site 7 on the same host

I am trying to enable emojis, so by following the documentation here

I have added the following to my configuration

  'charset' => 'utf8mb4',
  'collation' => 'utf8mb4_general_ci',

I have converted the MySQL tables into utf8mb4 format and set COLLATE to utf8mb4_general_ci.

In my drupal 8 site, the emojis work in drupal 7, I have the following error.

4 byte UTF-8 for mysql is activated, but not supported on your system. Please turn this off in settings.php, or ensure that all database-related requirements are met.

What else could be missing?

http request: use Drupal authentication with remote desktop without client

Is it possible to pass the authentication of an authenticated drupal user to a remote desktop gateway without a client (HTML5), if that user exits with the same credits with the gateway? Example, the user logs into the drupal site and selects a link that represents a remote web desktop connection (Apache Guacamole). Technically, the user would need to authenticate in the web RDC, but is it possible to use the same drupal authentication?

I can't seem to find a module for the remote web desktop client. Is there an authentication module that resends these credentials? Both sites would be using HTTP / S.

Guacamole has authentication add-ons such as OpenID, Duo / TOTP. If the drupal site uses OpenID and RDC web with openID, should the drupal user technically automatically authenticate to RDC web?

redirection – Drupal 8 – https with and without www at the base

I have implemented the website based on drupal 8.

global $ base_url; It is used in two different modules.

Module 1:

$content .= $base_url .'/user/role/1';

gives url pattern as:

Module 2:

$content .= $base_url .'/services';
gives url pattern as:

Is there any configuration or configuration that needs to be configured to get the same pattern when I call $ base_url?

centos – Blocking logins in Drupal 7 does not work

Dear colleagues

Good afternoon!

But once, I come to seek the help of this group. Some will surely remind me, with the PhpMyAdmin problem that I ended up solving with the update.

Now, I have the same problem with Drupal (and I can't update it). I cannot get fail2ban to stop login attempts with error.

What seems strange to me is that before migrating from the server, I used version 0.9.6-2 of fail2ban on Debian 9.12 and it worked correctly.

I migrated the server to CentOS 8.1 with fail2ban in version 0.10.5-2. And after that, the lock doesn't work.

I will share the configuration files with you:



/ var / log / messages:

I understand that the correct thing would be for fail2ban to block IP after the third login attempt, but it is not happening.

Can anybody help me?

I apologize for the possible typographical errors. I am Brazilian and I have difficulties with English.