Drupal Answers Community Digest

Top new questions this week:

How can I add a Pathauto pattern for a content type depending on a reference field?

On my site I have a content type 'Article' that has a reference field to a taxonomy vocabulary 'Type of Article' containing terms like 'Blog', 'News', etc. Now I would like to have Pathauto form a ...

8 path-aliases  
asked by C.A. Vuyk 3 votes
answered by leymannx 3 votes

How can I add a new field from config inside hook_update_N?

I have to add taxonomy by php code. Taxonomy has to got 2 fields. I added new function to test_taxonomy.install, and it seems to work: function taxonomy_update_8805() { $config_path = 'modules/...

8 taxonomy-terms configuration  
asked by Kapral Miś 2 votes
answered by leymannx 3 votes

How to disallow a view to display user's label (and some other fields?) when the user access is not allowed

I have created a very simple UserAccessControlHandler which return AccessResult::forbidden() is all cases: class MyUserAccessControlHandler extends UserAccessControlHandler { protected $...

asked by Baud 2 votes

Webform clone translation and caching issue

when i clone a webform programmatically i loose the translation. This is my code. //Load webform to duplicate $webform = \Drupal::entityTypeManager()->getStorage('webform')->load($default_template);...

8 webforms  
asked by nikitas michalakis 2 votes

How can I have a single QueueWorker run on cron for multiple Queues?

I have a site in which I associate multiple Config Entities with a single Queue ie. example_queue (using the default QueueInterface). My Config Entities produce records that are processed as queue ...

8 cron queue  
asked by baikho 2 votes

Do fields that are not displayed affect rendering performance?

This is a general question about how Drupal renders content. Say I have a content type with 20 fields, including some entity references, text fields, integers, and so on. When I have a lot of fields ...

asked by Patrick Kenny 2 votes

Pass User object to Token::replace

I've the following code (sample) that runs on Cron and sends SMS to users. $token = \Drupal::token(); $message = Hey, [current-user:account-name]; $message_value = $token->replace($message); ...

8 tokens  
asked by Krishna Mohan 2 votes
answered by Clive 2 votes

Greatest hits from previous weeks:

What are all the directories for in the new Drupal 8 structure?

Drupal 8 re-arranged all the directories and locations of modules/themes etc. Where do things go now?

asked by Letharion 52 votes
answered by Letharion 76 votes

How do I get the current path alias or path?

How can I get the current alias and/or path in Drupal 8? In Drupal 7 I did this with drupal_get_path_alias(). What is the equivalent code I should use in Drupal 8?

8 path-aliases  
asked by Yuseferi 69 votes
answered by rjacobs 131 votes

How to check Drush version?

How can I identify what version of Drush is installed on a given system?

asked by markdorison 35 votes
answered by Chaulky 46 votes

How do I maintain aspect ratio of scaled image with max-width?

When I use an Image Style that scales the original image, Drupal 7 (now 7.14) prints the height and width attributes in the img tag whereas before it didn't. So before, my CSS img {max-width: 100%;} ...

media theming  
asked by iainH 7 votes
answered by Clive 4 votes

The directory sites/default/files exists but is not writable and could not be made writable

We've recently had a few problems with our server, which seem to have been all patched up by myself, my host, and the cPanel team. However, since then we have been having problems with sites/default/...

asked by Mrweiner 6 votes
answered by chiddidilikahrn 20 votes

How to get instance of referenced entity?

I have a node object with image field named field_image. When I do $node ->get('field_image') ->first() ->getValue() I get array with some properties instead of entity object. The ...

8 entities  
asked by SiliconMind 41 votes
answered by SiliconMind 83 votes

Iterate through multiple value content field in Twig template

I need to take control over the rendering of a field_admin_tags field in a node.html.twig template. This WORKS: {{ content.field_admin_tags }} — Renders everything (label + all field values) {{ ...

theming 8  
asked by AngularChef 25 votes
answered by 4k4 19 votes

Can you answer these questions?

How can I set up an a SQLite memory database to improve PHPUnit test speeds?

I'm trying to speed up a functional Drupal test. Given a test... ... public function the_front_page_loads_for_anonymous_users() { $this->config('system.site') ->set('page.front', '/...

asked by tyler36 1 vote

Updating a Node image field from an external URL

I need to retrieve an image from an external URL and then save the image on Drupal's file system, and then set the image as the image for a node. In D7, this was a pretty simple task, but it's causing ...

8 nodes files  
asked by BlondeSwan 1 vote

Module listing page leading to php timeout

I am noticing that when I open the Modules listing page - admin/modules/ it leads to php timeout. There was no problem in listing out all the modules with drush. On opening the Modules listing Form in ...

asked by Binny 1 vote
You're receiving this message because you subscribed to the Drupal Answers community digest.
Unsubscribe from this community digest       Edit email settings       Leave feedback       Privacy
Stack Overflow

Stack Overflow, 110 William Street, 28th floor, New York, NY 10038