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.
1,754
questions
-3
votes
1
answer
42
views
Preventing one site from redirecting to www. prefix in multisite [closed]
I am using Drupal 9, multi-site. Generally, for all sites except one, i want to redirect from non-www to www prefix and i'm using the root .htacces file for it by uncommenting redirect rules. But the ...
-3
votes
2
answers
115
views
Update entityManager()->getViewBuilder from 5 year old site?
I have a Drupal 8 module which hasn't been updated for 5 years.
I m trying to update to current version of Drupal.
The error I get is
Error: Call to undefined method Drupal::entityManager()
The code ...
0
votes
1
answer
131
views
Prevent last updated property from changing when updating node in code?
I have this code that updates a node in a queue worker:
$changed = $entity->getChangedTime();
// Don't update the changed time by
$entity->setChangedTime($changed);
$...
0
votes
0
answers
89
views
Twig output not styled correctly
In one of my twig templates, I have:
<pre>{{ dump() }}</pre>
Twig output looks like:
Sfdump = window.Sfdump || (function (doc) {
Controller (partial code):
$renderable = [
'#theme' =&...
0
votes
0
answers
26
views
How to make a traditional entity field excluded from revision?
Is it possible to make an entity field excluded from revision? I want to avoid creating revision table for the field if possible. Otherwise, just excluding creating revisions is fine.
I tried to alter ...
0
votes
0
answers
15
views
Apply Context/Conditions to a Views result item?
If you are using Context for a node, the node itself typically comes from the node page you are on. In some cases, you may want to apply the same context to views results on a node as well - but they ...
4
votes
2
answers
491
views
How do I use \Drupal methods in a class?
I was out of Drupal for a few years, and PHP a couple years, due to having several years of jobs that didn't use Drupal between two that did. And I'm noticing a lot of functions that were reliable are ...
1
vote
1
answer
216
views
Is it possible to send an argument to a title callback?
I am trying to figure out how to set page titles on various pages. I have seen a lot of posts suggesting preprocess functions. These are not correctly setting the route's page title but only setting ...
5
votes
1
answer
189
views
Can services be autowired?
In drupal 8, each time we used to declare a class as a service by adding it to [module name].services.yml and then injecting it in the constructor of a different class. However, according to this ...
0
votes
2
answers
83
views
Change operator in a query?
I'm working in a Drupal 9 website.
I need to change operator in my view query from != to <.
In a view i got two contextuals filters:
The first to retrieve id from an entity reference field.
The ...
0
votes
0
answers
50
views
How to change markup of modal dialogs
A modal form is defined in openModalForm(), and the modal form is called by $form['open_modal'].
public function openModalForm() {
$response = new AjaxResponse();
// Get the modal form using the ...
0
votes
1
answer
84
views
How to make it so theme function isn't used when editing a node with layout builder
I have the following two functions in my .theme file that I'm using to gleam various bits of information from both the path alias and internal URL of the page being viewed. They are:
function ...
0
votes
0
answers
27
views
"Language missing or invalid"
I am using Drupal Version 9.5.5 and Forum core module.
After enabling the module and creating a forum container, forum, and topics, the module creates a page at /forum/ with a table list of the forums....
1
vote
1
answer
54
views
How can I render comment pager on the top and the bottom of the comments portion of the page
When comments are numerous on a node and you have a high comments per page setting, you have to scroll a lot to get to the pager.
My users have requested pager at top as well as bottom of the comments ...
-3
votes
1
answer
45
views
Does Drupal core include any comment spam prevention mechanism?
I have a Drupal 9 core website and I have allowed comments in it (approval needed).
The problem is that my website is flooded with spam boots posting links in pre-approved comments. This causes burden ...
-2
votes
1
answer
370
views
Issues updating from 9.4.3 with composer
I have a project that wasn't updated since a few months and I am stuck on 9.4.3 with composer refusing to update.
Here is my composer.json
{
"name": "drupal-composer/drupal-project&...
0
votes
1
answer
184
views
Using the off-canvas dialog, how can I submit and close it, without redirect?
I use this as link:
<a
class="use-ajax"
data-dialog-options="{"width":800}"
data-dialog-renderer="off_canvas"
data-dialog-type=&...
1
vote
2
answers
140
views
Replace MessageTemplate with token value and send the message
I'm having some trouble getting the tokens in my Drupal 9 message template to work properly. I have created and saved a message in my UI using the structure->message templates section, with a ...
1
vote
0
answers
29
views
How do I make a subgroup of custom tokens under the Nodes top level token group?
I have a few custom tokens to create which are based off of node context. At first I thought I could have them as their own top level group with code like this:
$info['types']['mpep_policy'] = [
...
0
votes
0
answers
150
views
Get link to content in entity reference field template
I have an entity reference field set in Manage Display to 'Rendered Entity' and am working with the field's template to conditionally show the link based on the referenced node's published status. I'm ...
0
votes
1
answer
43
views
how to alter entity reference field (taxonomies) field options in hook form alter
Can anyone please let me how to alter entity reference field (taxonomies)
field options in hook form alter,
Seems the below code doesn't work.
/**
* Implements hook_form_alter().
*/
function ...
0
votes
1
answer
26
views
Unable to update node entity fields using custom form
There is a certain content type, in which there is a field to enter a node or taxonomy.
I want to create a new node for that content type using a custom form and register the node or taxonomy in the ...
1
vote
1
answer
142
views
States on input type button broken since core update
I've updated my Drupal project from 9.5.3 to 9.5.7, but the submission button's #states property stopped working.
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Accéder au ...
0
votes
0
answers
34
views
can't get multistep ajax webform work with computed field
When ever I use multistep webform with computed field and try to enter data in second page, webform redirect me to first page with validation error.
Source code of my webform,
page_1:
'#type'...
0
votes
1
answer
298
views
Adding cache tags to custom block
I have a custom block which load some taxonomy terms.
When I made changes to my taxonomies, the block isn't loading the new data (due to the cache). I'm passing all my taxonomy tags to my #cache ...
0
votes
1
answer
87
views
Error when trying to retrieve a term with ajax
We are creating a custom form to edit a certain node.
We do this above because there are some things that cannot be accomplished with the default form.
I want to use AJAX to populate the fields of the ...
0
votes
1
answer
66
views
How to modify the timezone options list?
I have a date range field in a paragraph which is set to allow setting the timezone. Can someone suggest how I can alter the list of options used to select the TZ?
For the user profile form a simple ...
0
votes
1
answer
121
views
Stick comments on top
I need to stick specific comment on top of others which will remain from oldest to newest.
When it's stick on top it's replies must be with that comment.
So
I made links in .module file which will ...
0
votes
1
answer
61
views
How do I display a block after changing its ID?
I have a custom block. I want to change its ID, but after I changed it from main_menu_block to header_block, the block is not displayed anymore.
I tried to:
Remove the block with the old ID
Change ...
0
votes
1
answer
49
views
How to disable the option time_restriction that honeypot add to the forms
In the README file for the Honeypot module, it says:
If you want to add honeypot to your own forms, or to any form through
your own
module's hook_form_alter's, you can simply place the following
...
0
votes
0
answers
24
views
EntityQuery to filter values returned based on List(text) field
I have a List(text) field that can have multiple values. I am trying to create an entityQuery that returns nodes with specific items are checked within the field. The variable "availableServices&...
1
vote
0
answers
23
views
Always charge the most expensive flat rate shipping in an order
I have a Drupal Commerce site with two product types. One has free shipping, and the other costs € 3,-. When both products are in the cart, the customer is allowed to choose either of those rates, ...
-1
votes
1
answer
444
views
Argument #1 ($config_factory) must be of type Drupal\Core\Config\ConfigFactoryInterface, array given
I'm writing a new module for the community and I have this error and I'm not understand what's going on.
The error:
Mensaje TypeError:
Drupal\view_mode_by_owner_role\Functors\ListOfNodeBundles::...
0
votes
1
answer
117
views
Creating a Custom Content Listing Page based on specific content type or taxonomy terms selected in the node
I am trying to create a content type that generates a list of content/nodes based on other content type or taxonomy terms selected within that node in the content type. I have a general content type ...
0
votes
1
answer
248
views
When a custom form is displayed in a custom template, ajax does not work
What I want to do
I want to display a custom form with a custom template and use ajax in it to change values in the form.
Problem
Custom template notation prevents ajax from working.
I didn't change ...
1
vote
2
answers
161
views
Why is the service “@url_helper” not found?
I am trying to add the query string with the each URL access through the browser. To accomplish it, trying to implement that through the service. But getting no solution in Drupal 9.
mymodule.services....
0
votes
0
answers
28
views
Can't Place Custom Block in BrowserTestBase
I'm trying to set up a test for my custom module. But I can't seem to place my custom block. I can place system blocks just fine. So I don't know if there's something special with a block I make in my ...
-1
votes
1
answer
240
views
Patch not working
I am trying to apply patch to the core file but none solution work for me. even not able commit core file changes due composer restriction
composer.json
{
"name": "pantheon-upstreams/...
0
votes
1
answer
90
views
phpunit can't find node permissions
We have a Functional test class derived from BrowserTestBase which is passing, but the output includes a deprecation notice.
Adding non-existent permissions to a role is deprecated in drupal:9.3.0 ...
0
votes
0
answers
30
views
Report comments / Workflow
I am trying to implement a functionality that would allow authenticated users to report comments on a forum post. My first thought was to do it using workflows but comments dont have a workflow ...
0
votes
0
answers
51
views
Fetch redirect alias using the old alias
I want to get the current alias of the node using an old alias. I do have the Redirect module installed and all the old aliases of the nodes are mapped to the new ones. But I am not able to fetch the ...
0
votes
1
answer
110
views
tempstore.private not working in openIDConnect client
I am getting some licence info via retrieveUserInfo in the openIDConnect custom client login process. Ideally i want to write it to the session but opted for the "tempstore.private" since it ...
0
votes
1
answer
67
views
401 error when trying to retrieve OAuth authorization code
I'm building a decoupled Next.js frontend to consume data from Drupal JSON:API on a local site installed with Lando. I want to use the simple_oauth module to allow registered users to edit content on ...
0
votes
0
answers
54
views
Save multiple taxonomy terms in migration from array of tids
I'm having some issues with storing multiple taxonomy terms in a field as part of a migration.
I've created a custom plugin get_colors that returns an array of existing tids. A custom process plugin ...
0
votes
1
answer
47
views
Deleted context link still exists in admin toolbar menu
I have deleted context but in admin toolbar it still showing . On main context admin page context doesn't exists. I have installed/uninstalled module - not helping
How do i remove that link from ...
1
vote
0
answers
119
views
"migrate:status" freezes on "Try to validate bootstrap phase 0"
Drupal community!
I am working on migrating from D7 to D9. Both are located on separate servers. I configured D7 database as db to migrate in my D9 settings.php, like this:
$databases['migrate']['...
2
votes
1
answer
163
views
CKEditor 5 - access PHP plugin configuration from JS plugin?
I have provided a CKEditor 5 plugin a PHP configuration class. I am able to set and store configuration for the text editor plugin now, but do not know how to access that configuration value(s) from ...
1
vote
0
answers
74
views
How do I migrate 1000+ nodes iteratively with term hierarchy and links in a CSV file? [closed]
I run for almost 15 years now a Drupal website as a hobby. I had lots of help of the great Drupal commmunity with this. And was able to migrate from drupal 5-6-7 with the modules which were add hand. ...
0
votes
1
answer
40
views
Export product image with Commerce Cart API module
I'm usng the "Commerce Cart API" module on my website to build a custom cart js layer.
The problem i am facing is the purchased entity has a field_image field and I would like get the url of ...
0
votes
1
answer
21
views
Auto assign term to node from term field from user
I have a term field called "Organization" on both Content and User entities.
On the Content entity, the field for Organization is hidden.
For the user, they select a value for Organization.
...