Drupal Answers Community Digest

Top new questions this week:

Is it Possible to have a nested Select Statement in a Where clause using Dynamic Queries

In my Drupal Query I need to recreate something like this using a dynamic query: WHERE (node_field_data.status = 1) AND (node__field_document_places.entity_id IN (SELECT entity_id FROM ...

database  
asked by Rubix05 Score of 2
answered by Clive Score of 2

Can I know what I'm looking at from the URL?

I think on Drupal 7 I had previously used something like menu_get_object() to find out what content I was on. For example, with mysite.com/content/my-page, it would tell me that this was a node, its ...

8 uri  
asked by Andrew Morris Score of 2
answered by 4uk4 Score of 2

Alter jsonlog data

I am looking to alter the generated output of the log files from the contrib module JsonLog - https://www.drupal.org/project/jsonlog/ The logger generates a .log file, which I need to customize with a ...

9  
asked by Ivan Ginovski Score of 2
answered by Hudri Score of 3

How to check if secondary database definition exists

Can anyone please help me on how to check if secondary database is set. If not throw an error. I am currently defining database connection as below. Database::getConnection('default', 'sqlite') I am ...

database 9  
asked by miststudent2011 Score of 2
answered by apaderno Score of 2

Selective cancellation from Watchdog

Can I selectively DELETE rows from watchdog? I have annoying errors and warnings I'm slowly getting rid of, but I would like to keep the history of user actions (create, update and delete on content). ...

8 log-messages  
asked by Francesco Marchetti-Stasi Score of 2
answered by Patrick Kenny Score of 1

refresh form_token with refresh page

Unfortunately, the form_token does not change when I refresh the form pages. Doesn't this cause abuse and security risks? Can anyone explain what Drupal does for CSRF in all its forms? Thanks

9 security csrf  
asked by reza Score of 1
answered by Yuseferi Score of 1

Set nested value in storable config

I have a settings form that saves site wide configuration information My submit form function looks something like this $data = []; foreach ($groups as $key) { $data[$key] = $form_state->getValue(...

9 configuration  
asked by Matt Score of 1

Greatest hits from previous weeks:

Adding CSS and JS to form with attachments

I need to add some external and local CSS and JavaScript files to a form, but I can't seem to find the right way to do this. Do I simply add the paths and URLs for the JS and CSS files? I assume $...

7 forms  
asked by vintorg Score of 40
answered by Alex Gill Score of 73

How do I correctly setup caching for my custom block showing content depending on the current node?

I have this very basic block which just shows the current node's ID. <?php /** * @file * Contains \Drupal\mymodule\Plugin\Block\ExampleEmptyBlock. */ namespace Drupal\mymodule\Plugin\Block; ...

8 blocks caching  
asked by Alex Score of 29
answered by Vagner Score of 47

How do I get the user ID for the currently logged-in user?

I want to get current user object (user information) in Drupal 8. I know in Drupal 7 there was a global $user variable; I want to know how I can get current user object in Drupal 8.

users 8  
asked by Yuseferi Score of 34
answered by DRUPWAY Score of 25

Hide a field label

Is there a way to hide the field label when rendering a custom field in Drupal 7? In my node template I have: <?php print render($content['field_image']); ?> Which gives me: <div class="...

7 theming entities  
asked by Ben Score of 21

How to get taxonomy term name from tid?

A lot of our stuff has uris formatted like site/taxonomy/XX, where XX is an integer. I found a lot of questions like "how to get the TID from the name?", but I'd like to get the name from the TID. I'...

7 taxonomy-terms  
asked by Brodie Score of 35
answered by Clive Score of 97

How do I get the current node ID?

In Drupal 7, if I wanted to get the node id of the currently displayed node (e.g. node/145) I could get it with the arg() function. In this case, arg(1) would return 145. How can I achieve the same ...

nodes 8  
asked by dbj44 Score of 66
answered by Clive Score of 135

Drush needs a higher bootstrap level to run

Do you have any idea on what might be causing this error when I execute: drush si geoslate --db-url='mysql://root:root@localhost/geoslate' --site-name=Geoslate Command site-install needs a higher ...

drush  
asked by Andrew Welch Score of 16
answered by 4life Score of 19

Can you answer this question?

How can I load a migration in a KernelTest?

I'm trying to test a migration with a KernelTest, but I'm running into an issue when I try to load the migration plugin. My migration is defined in my_module/migrations/my_migration.yml. In my ...

migrations testing  
asked by sonfd Score of 1
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

<3