Hot answers tagged

3 votes
Accepted

Does deleting a content type also delete all nodes of that type?

The confirmation message that Drupal 7.58 shows in English is the following one, where %type is the content type name and @count the number of nodes. %type is used by @count pieces of content on your ...
  • 95k
3 votes
Accepted

Changing the PHP memory limit in settings.php is not reflected in phpinfo()

You are probably calling phpinfo() before settings.php. What if you use the built-in phpinfo() linked in the Status Report? http://www.example.com/admin/reports/status/php
  • 90.4k
3 votes

How is the theme folder to use decided?

You should never, ever keep a duplicate/backup copy of any theme or module anywhere under /sites/all. You can't control which copy Drupal will find first, and you may actually be using parts of both. ...
  • 2,029
2 votes

Weird Character output Field Collection data with Views Data Export (CSV)

I know I am a few years late to the answer, but if there are UTF-8 characters like  in your data, you can decode it by setting "utf8_decode" in the character encoding conversion field in ...
2 votes
Accepted

How should I remove nodes from database for which the content type was deleted on Drupal 7.58?

The easiest thing to do would probably be: Create the content type you deleted, the important part here is to give it same machine name as before, this will make the old nodes that exist in the ...
  • 35.2k
2 votes
Accepted

'Aggregate and compress CSS files' and 'Aggregate JavaScript files' don't work

Well it turns out that mod_headers wasn't enabled on my server, which therefore meant that the '# Rules to correctly serve gzip compressed CSS and JS files' section within .htaccess didn't work. It ...
  • 161
2 votes

How can I overwrite existing file and keep same filename when uploading new

You can just use the Upload File Replace module to solve this use case instead of custom code: This is a small utility module that automatically stops Drupal from renaming new files upload via ...
  • 21
2 votes

How to bypass node_access when using EntityFieldQuery?

For Drupal 8 you can use: $query->accessCheck(FALSE);
  • 3,541
1 vote
Accepted

Getting error "PHP files in the Drupal files directory can be executed." in Security Review v.7.x-1.3

Security Review actually places a PHP file in that directory and executes it, proving that PHP execution is possible. In addition Security Review checks for the existence and the contents of an ....
  • 3,643
1 vote

Hide images for articles that are older than two weeks

Drupal 7's *.tpl templates still support PHP. If you have access to those templates, wrap printing the images in an according if condition statement. You'll wan't to compare the article creation time ...
1 vote

Can't add Google Webmaster metatag because "Site Verification" category is missing

Step 2 in the guide says to install the "Metatag Verification" submodule, that's included as part of the Metatag module suite so it should already be in your site's directory structure. ...
1 vote

How do I find out which system.info my site is using?

The system.info file is simply the file containing information for the System module. As such, there should not be more than a system.info file in a Drupal site, except in the case you copied the ...
  • 95k
1 vote

How do I find out which system.info my site is using?

The Drupal 7 Core version is in includes/bootstrap.inc on line 10, not in a .info file. Example: define('VERSION', '7.91');
  • 3,643
1 vote
Accepted

User login doesn't work after server migration

After a lot of debug I found the issue in settings.php file ini_set('session.cookie_secure', 1); for HTTPS site the session cookie must be secure but as the current site is HTTP, so we need to turn ...
1 vote

Disabling Browse to Library in Media Upload Field

On Drupal 8+ go to: /admin/config/media/browser Set the "Enabled browser plugins" to only "upload" and save the page. Now when people click on the button in the WYSIWYG to add ...
1 vote

How to prevent a node from being saved/updated by using the Rules module?

The following rule (using the Rules module) has been built to prevent the node from being saved/updated if the field 'a' is larger than 5. Rules is absolutely the wrong place to be doing this. Once ...
  • 2,029
1 vote

check if a page has been redirected and then add a class to a certain div

Instead of redirecting to /page you redirect to /page?hello=world then you can check in JS for that URL query param and fire your magic.
  • 16.2k
1 vote

How to put a site in maintenance mode by non-admin

For Drupal 7/8/9 you can use the module Custom Permissions for that. You have to (Drupal ^8): Install the module Custom Permissions Go to settings page /admin/people/custom-permissions/list Set the &...
  • 81
1 vote

Enable error logging from settings.php

Please try the following: in the webroot, rename .htaccess to .htaccess.old -- Apache 2.4 has changed syntax in some directives that may be causing the error before PHP is even reached. Also check ...
1 vote

Enable error logging from settings.php

Here's the official manual for Drupal 7: https://www.drupal.org/docs/7/creating-custom-modules/show-all-errors-while-developing At the end of your sites/default/settings.php, add the following lines: ...
1 vote

How can I use pathauto to generate URLs for deeply nested vocabularies?

I case someone is looking for a Drupal 9 answer, here it is: /[term:parents:join-path]/[term:name]
1 vote

SMTP module cannot connect to smtp.gmail.com

I needed to use an app password. This is done at https://myaccount.google.com/security Before creating an app password, you have to turn on 2-factor authentication for the account.
1 vote

How can I access or expose the Commerce data in $order->data[] to the Rules module?

You can't really expose data as such, but you can define your own order property via hook_entity_property_info() with a custom callback that returns the specific value from the data array you want. ...
  • 6,670
1 vote

How do I get the public url of a file from the uri or filename

In Drupal 8 you can use the file_url_generator service Drupal::service('file_url_generator')->generateAbsoluteString($uri) Because the file_create_url($uri) function is deprecated: https://www....
1 vote

How to delete a node or a list of nodes with Drush?

If you want to delete all nodes use the range() function as drush php-eval "node_delete_multiple(range(1,3000));"
1 vote

How do I get the full URL of the current page?

The question is pretty old but chiming in for people that might get there for a more recent version of Drupal. You can get the current full-path for a page with: $path = \Drupal::service('path.current'...
  • 133
1 vote

Custom form adding a commerce price field

this works for me $form['price'] = array( '#type' => 'commerce_price', '#title' => $this->t('Price'), );
1 vote

What is the use of Drupal.settings.ajaxPageState object?

The ajaxPageState object is used to collect already loaded theme assets (css, js files in Drupal 7, libraries in Drupal 8 and later) and pass that on to Drupal when doing AJAX requests, so that assets ...
  • 2,705
1 vote
Accepted

How to get rendered node according to active theme?

It is definitely because your admin theme is active when you do the render. There is no straight-forward and easy way to switch the theme in the middle of a request and you will likely run into ...
  • 2,705
1 vote

Translation of a multilingual site into English

As mentioned in the comments, Always start with English string and translate that even if it's a one language only website, to ease the pain here's what I always do to keep the strings and ...
  • 1,554

Only top scored, non community-wiki answers of a minimum length are eligible