


How can I add multiple conditions for the same field taxonomy term in views query?
I make some query for views filter for nodes. Use in hook_views_query_alter. $definition = [ ‘table’ => ‘node__field_characs’, ‘field’ => ‘field_characs_target_id’, ‘left_table’ =>... read more
Changing Twig template of form items through the theme
I have a block, which renders out a form using code that looks like this: {{ attribute(form.facets, ‘filter_’ ~ filter.name) }} I’d like to amend the markup and CSS classes for the various elements that are output, including fieldset, input, label... read more
How to use helper/private methods with a .module file?
Let’s say I use a hook with a lot of code inside. To improve readability and reusability I’d like to use helper/private methods. However, a Drupal .module file is not a class. The idea is to split big methods from this file into more readable and reusable... read more
Related Content By Taxonomy Term and fields
I have a content type which has taxonomy term field (Department). There is another field of the same taxonomy term (Priority Department) I want to create a list of related content where the block shows only priority department related content and not the department... read more
Change the default "Create new account" title on the User registration page
I would like the change the default title (and probably also the meta title) of the User registration page, currently “Create new account”. I tried the Static and Dynamic page title method described here, as well as a couple of other suggestions, but none... read more
How to override output (query) for views exposed filter?
I have a views with exposed filter of taxonomy terms (select). It have multiple choice, and nodes output with that terms. But I want to change output of result of views for this filter. How can I do it programmatically? read more
Update entity properties fetched with entityTypeManager()->getStorage
I am loading all entity types I need to update like below $current_fruit = Drupal::entityTypeManager()->getStorage(‘fruit’)->loadByProperties([‘status’ => ‘1’]); Then I update them in a way that I loop through the object... read more
Retrieve author / owner of term
I am loading a term and trying to get the author or owner of the term, however I can not see any function under the Term Class On the other hand I can see the translation author being present on the edit page. Any way to retrieve author for Term? read more
Drupal EU Cookie Compliance module conflict with theme JQuery
When I first installed the module, it’d only appear in admin pages. After some investigation, I discovered the cause was some sort of conflict with my themes jquery: jquery-1.11.2.min.js. If I disable it, the module works. If I enable it, the module... read more
Drupal.org Project Pages 5xx Server Error
Hi, Im getting a 5xx Server Error when trying to view any project page on Drupal.org, such as module and theme pages. Not sure if its me or you, really appreciate any info. Many Thanks, Shane. O read more
Programatically set the language
I’m trying to automate the setup of Drupal multi-site installations as much as possible, we’re using each multi-site for a separate country so would like the languages localised for each. Is there a way to programmatically set the default language? It... read more
How to overwrite a file upload so that the filename is always the same?
I am trying to implement a file upload form in which files are saved. I had written the following code <?php /** * @file * Contains Drupalavenue_product_importFormavenue_product_importForm. */ namespace Drupalavenue_product_importForm; use DrupalCoreFormFormBase;... read more
Force redirect back to password form until password got set after one-time-login
When my users click on a one-time-password-reset link then I log them in and then show them a page where they can choose their new password. Problem is that there are two additional links on that page (one for dashboard and some other one) and they can click on them... read more
hook_node_view_alter not working
I’m hoping to finally find some solutions here. I’m new to custom module development in Drupal and I’m trying to learn the basics. What I’m trying to do is use hook_node_view_alter, however even at the simplest step (showing a status message)... read more
How do I clear the cache for a single node?
In my module, I can call cache_clear_all() (D7) or drupal_flush_all_caches() (D8), and this would clear the cache for all the nodes. Is there a way to clear the cache for a single node? What I need to do is setting up a module that, when it selects a story on a list,... read more
Error in Italian localization for datepicker
Well, this is very funny 🙂 I have a datepicker localized in Italian. It works correctly, except that, apparently, the abbreviation for Wednesday was translated as it were a personal pronoun, since noi is the Italian translation for we. The abbreviation for Wednesday... read more
How can I update Drupal core and all modules / themes in one go from the command line?
On a LAMP environment, I have a Drupal site which uses the default theme and a few stable contributed modules. Nothing is customized, and I have daily backups so I don’t "fear" of updating. How could I update core, modules, and themes in one go from... read more
SymfonyTestsListener does not exist on PHP Unit Test
When I try to run a unit test I get an error that SymfonyTestsListener does not exist. Am I running this correctly? ../../vendor/bin/phpunit -c phpunit.xml ../modules/custom/my_module/ Class “SymfonyBridgePhpUnitSymfonyTestsListener” does not exist I am... read more