Questions tagged [9]

Version tags should be used only for questions that apply to a version only, not to merely say what version a site is using.

Filter by
Sorted by
Tagged with
14
votes
2answers
9k views

Load a file entity by URI

Is there a way to load a file by URI in Drupal 9 and/or Drupal 8? In Drupal 7 it is possible using the following code. $uri = 'public://file.xyz'; // Take a look at: file.inc::file_load_multiple $...
12
votes
3answers
1k views

Require v8 only contrib module with v9 patch

Given I have Drupal 9 composer installation with composer-patches plugin and given a contrib module with a stable v8 release, but no v9 release (not even dev branch) and given that contrib module has ...
12
votes
2answers
4k views

Command to install Drupal 9 with Composer

The latest version of Drupal 8 can be installed via Composer with the following command: composer create-project drupal/recommended-project mynewproject What is the equivalent command to install the ...
11
votes
1answer
470 views

Should I use Drush or Drupal Console with a new site?

Between Drush and Drupal Console, which seems to have similar functionalities, which one should I install?
8
votes
2answers
341 views

Use custom content entity theme suggestions in own module?

I have a custom content entity called 'offer'. I've added template_preprocess_offer() and offer_theme() to the offer.module file. function offer_theme($existing, $type, $theme, $path) { return [ ...
6
votes
1answer
124 views

What method should I use instead of Drupal\Core\Entity\Query\Sql\Query::addExpression()?

I am using Entity Query to select nodes of two different types. The fetching seems to be working, but I to sort the returned values. Both the content types have different date fields. I know I could ...
5
votes
3answers
341 views

How can I restrict external URLs in link field to allow only certain domains?

After creating a Link field and use the Link with service icon format, I find out that there is no option to restrict external URLs to external domains that I want For example, if I only want to allow ...
5
votes
1answer
396 views

Locked myself out after enabling misconfigured Google Authenticator

I somehow managed to lock myself out of a Drupal 9 installation after setting up TFA with Google Authenticator login. So, i know my user1 name, my user 1 password, but TFA doesn't allow me backend ...
4
votes
1answer
245 views

How to add a js script as type="module"

How to add type="module" to script added in MODULENAME.libraries.yml when i do: my-library: version: 1.x js: js/App.js: { } I get <script src="/modules/custom/MODULENAME/js/...
4
votes
1answer
157 views

Drupal 8's last minor release = Drupal 9?

I have read about the planned release date of Drupal 9 is scheduled to be on June 3rd, 2020. I read this documentation about how to prepare a Drupal 8 site for Drupal 9: Prepare a Drupal 8 site for ...
4
votes
1answer
89 views

Force a single value base field to be in a separate table?

I have a custom entity type (eg: myentitytype), and I would like to add a new base field to it via hook_entity_base_field_info(). As I understand it, single value fields (with a cardinality of 1) will ...
4
votes
2answers
54 views

Alter comment pager to jump to comment section right away?

I set up a content type and a specific comment type for this content. I set the comment pager to display 10 comments per page. When I now use the pager, I get redirected from the node URL itself www....
4
votes
1answer
61 views

How to prevent a node from being deleted while performing a delete operation?

I want to prevent a node from being deleted while a delete operation is performed on it. For example in administration panel if user clicks "Delete" on the node, the node shouldn't be ...
4
votes
0answers
41 views

What is the difference between Translation language, Translation source, and Original language?

Would anyone be able to explain to me what the difference is between "Original language", "Translation language", and "Translation source"? I think I have a pretty good ...
4
votes
1answer
88 views

How can I have Behat create content with an address field properly filled?

I'm writting a Behat test, where I'm triying to create a content that uses a field address, generated by Address Module. I'm using Drupal 9.0.7, Address Module 1.9.0 and behat 3.8.1. My goal is to ...
3
votes
1answer
365 views

How can I use core's WebP support instead of the WebP module?

According to the change record, Drupal 9.2 supports WebP for better image compression. I've been using the WebP module on my 9.1 site to serve WebP images, but it has a performance-killing bug and I ...
3
votes
1answer
66 views

Mocking Settings (settings.php) within Unit tests

Drupal's Settings class is marked final and has no interface, meaning traditional PHPUnit mocking techniques will not work out of the box. Is it necessary to install third-party tools to be able to ...
3
votes
1answer
184 views

Can we add custom CSS class in \Drupal::messenger()->addStatus()?

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 ...
3
votes
1answer
176 views

How to properly manage field types for a content type created by a module?

I'm a bit confused about two different errors I get, which seem to contradict each other. I guess I didn't register my field types properly. The first one appears when I try to uninstall my module. ...
3
votes
1answer
241 views

Add webform field programmatically

In older versions of Webform (Drupal 7), the function webform_component_insert() can be used to add fields to a webform, for example inside a hook_node_insert() implementation, so they are added when ...
3
votes
1answer
64 views

Exclude settings from a contrib module on export

I've two environment, dev and staging. I'm using the ReCaptcha module. In the developpement environment, I have some api keys a other config which until now, are exported thanks to drush cex inside ...
3
votes
1answer
215 views

Disable caching for a front page path processor

I’m working on a project where users can create a book (core functionality). In a simple text field they can connect a domain to this book. This way the book is only accessible via this domain. For ...
3
votes
1answer
434 views

Date Field Type - Text Field Widget is Gone?

I am noticing that the Date field type only has the availability of three widgets: Select list Date and time Select list, no time Can someone tell me why the "Text Field" widget is gone? ...
3
votes
1answer
119 views

Page titles are wrapped in a span tag

On a site we are working on I was asked why the page titles are wrapped with a span tag. We are not using a base theme. I checked everywhere I could think of, but came up short. In page-title.html....
3
votes
2answers
228 views

Can I create non-default EntityReferenceSelection?

I have the following EntityReferenceSelection plugin: /** * Provides an entity reference selection for my_entity. * * @EntityReferenceSelection( * id = "extra:my_entity", * label = &...
3
votes
1answer
411 views

How do I run PHPUnit tests?

Having just kind of gotten my head around Simpletest functional testing in Drupal 8.x, I've now started trying to use PHPUnit testing since Simpletest has been deprecated in Drupal 9.1.x. I started by ...
3
votes
1answer
80 views

No results behavior not showing on a view

I have a view, and the no results behavior is not showing even when there are no results. The view shows all nodes tagged with the same term as the current node. This is done with two relationships ...
3
votes
1answer
70 views

How to get Automation testing results of Drupal contributed module through Drupal.org rest API?

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 ...
3
votes
1answer
270 views

How do I replace drush_set_error()?

Just updating a module for Drupal 9 and Drush 10 and drush_set_error() no longer appears as a function in the Drush code (as far as I can see). What should I be using instead?
3
votes
1answer
76 views

Is there an event related to the creation of a session cookie for anonymous users?

I need to set an additional cookie whenever an anonymous user received a session cookie. This happens when selecting a facet in Search API for example. The specific use case is that I need an extra ...
3
votes
0answers
19 views

QuickEditIntegration can't process components for Quick Edit

I have a content type that is displayed with Layout Builder. When I view it in default mode, the Quick Edit option does not appear in the contextual menu. This is because none of the fields have the ...
3
votes
1answer
38 views

How to get all search results of search api index?

I want to get all the search results from the search API index and then perform a custom sort on it and then display them accordingly. I used the hook_search_api_results_alter and also the search ...
3
votes
2answers
170 views

Installing Acquia BLT on an existing site

We have a working Drupal 9 installation (running within Docksal), which has pretty much the whole install living in docroot/ except for the config/ directory, which is a sibling of docroot/. This ...
3
votes
0answers
65 views

Menu link tree only loads enabled elements in subtree regardless of parameters

When loading a menu tree without any custom parameters: $tree = \Drupal::menuTree()->load('my-menu-name', new MenuTreeParameters()); The returned tree \Drupal\Core\Menu\MenuLinkTreeElement[] ...
3
votes
0answers
102 views

How can you require users to change their passwords on first login after migration?

We are planning to migrate users from another CMS to Drupal. We can migrate usernames, but not passwords as the encryption is different. So we shall have to assign passwords to them. Earlier versions ...
3
votes
0answers
568 views

Site errors out when trying to create a subtheme based on Classy

I'm creating a custom theme in Drupal 9 and am trying to use classy as my subtheme but get the following error: The website encountered an unexpected error. Please try again later. Drupal\Core\Theme\...
2
votes
3answers
3k views

How do I fix the The service "sanitize.userfields.commands" has a dependency on a non-existent service "entity.manager" error?

I am running Drush the first time in a Drupal 9 site. I get the following error. In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86: The service "sanitize.userfields.commands" has ...
2
votes
1answer
306 views

What does the "Views: Filter by an entity reference view" reference method do?

I was just creating a reference type and noticed that there is a reference method called Views: Filter by an entity reference view. What does this do, and how does it differ from the Default method? I ...
2
votes
4answers
4k views

How to delete a webform submission in a custom module?

I want to delete a webform submission from a custom module that I've written. I'm using webform_submission_delete(123, 76). The error I receive is: Notice: Trying to get property of non-object in ...
2
votes
1answer
169 views

What is the route for a specific node?

I want to override the user.login route that points to the default login page. I.e. I want that a user who presses the default "Log in" link for the site to be directed to a node that ...
2
votes
3answers
1k views

Upgrade Devel module and disable Kint

When upgrading from Devel 8.x-2.x to Devel 8.x-4.x in a composer based build, how do I handle the Kint module being removed per Remove Kint module and create a kint dumper plugin in devel? The service ...
2
votes
1answer
270 views

What should be used instead of raw filter?

Drupal 9 theming documentation indicates that the Twig raw filter is deprecated in favor of verbatim. The ds-field-expert.html.twig template uses raw to render the input in the prefix and suffix field,...
2
votes
1answer
86 views

In event subscriber, how to redirect if value doesnt exist?

I am trying to check a condition before page load, if value exists to load page if not to redirect. I am following this page I have created a /mymodule/mymodule.services.yml file and a /mymodule/src/...
2
votes
2answers
187 views

PostCreate/Hook on User Registration

I want to hook into user registration but there doesn't seem to be any hook for it anymore. This is what I see from Drupal 8.8: hook_user_cancel hook_user_cancel_methods_alter ...
2
votes
1answer
134 views

How do I generate taxonomy terms with drush 10/drupal 9.1.x [closed]

I'm trying to use drush to generate some taxonomy terms for a sandbox/development instance. This might be an error report by I'm a drush noob so I wanted to ask first. When I run drush devel-generate:...
2
votes
1answer
26 views

Where is "click sortable" set for a field?

I am trying to properly fix a bug in D8/9 core which removes the ability for link fields to be "click sortable" in a Views table. I know I can do a views_data_alter hook to set the field as &...
2
votes
1answer
44 views

Change priority of different aliases with the same aliases

There is vocabulary, let's call it forum tags which contain all forum tags, Also, in Forum, the link for the Forum container using a similar tag pattern for the forums. for example, Term name : ...
2
votes
1answer
122 views

How do I programmatically publish the latest revision?

My workflow is draft and publish. I create and publish a page. I create a draft of the page. There is now the published page, but the latest revision is the draft. How do I programmatically set as ...
2
votes
2answers
117 views

How to expand NodeForm so new argument can passed to it

I have a content type called service request, which have some conditional fields that each might appear or disappear based on an other field value called service type. I have used conditional field ...
2
votes
1answer
183 views

How to add comment form to a view of nodes in Drupal 9?

I'm using views to display the fields of nodes. I prefer to use fields because it allows me to use relationships (bring in author profile picture etc.). Adding the Content: Comments field shows the ...

1
2 3 4 5
14