All Questions

143
votes
11answers
177k views

What are the recommended directory permissions?

I'm gearing up to deploy a Drupal 7 site and I can't find any documentation about what are the recommended security-conscious file and directory permissions should be set. Specifically default/files/ ...
134
votes
16answers
73k views

Why is Drupal 7 so slow? [closed]

I just created a new Drupal 7 website and the loading time is too much. I checked with Speed Tracer from Google and here are the results for the first page: URL http://mysite.com/ From Cache false ...
122
votes
14answers
17k views

What is the basic concept behind hooks?

I am intermediate in PHP. To polish my skills I start learning Drupal 7. While learning Drupal architecture concepts, the terms hooks and bootstrapping puzzled me a lot. I read the "Pro Drupal ...
105
votes
3answers
65k views

Views contextual filters taxonomy name

I'm adding a contextual filter to a view for a custom content type that has a taxonomy field. The contextual filter allows me to filter by the taxonomy tag id but not by the taxonomy tag name. Meaning ...
100
votes
1answer
38k views

How should I implement hook_menu()?

What are the fundamentals of implementing hook_menu()? I would like to see the basics covered in a single question, to avoid having to answer the same similar but different questions over and over.
97
votes
6answers
14k views

What are the downsides of using PHP Filter code in blocks, nodes, views-args, etc?

I have seen many times people saying not to use custom PHP/PHP filter (from the Drupal UI) in blocks, nodes, views-args, rules, etc. I have searched around a bit and haven't found much, it seems like ...
92
votes
9answers
8k views

Do non-enabled modules affect performance?

Does having Drupal modules present, but not enabled have any effect on the performance of a Drupal site? To put it another way.. Would removing disabled modules from a Drupal site have a positive ...
84
votes
6answers
15k views

When is it appropriate to create an Entity versus just adding a new content type?

What is the benefit to creating new entity types over just building a new content type? It seems a bit overkill to do all of the custom coding that is required to create a new entity when you have ...
82
votes
7answers
8k views

Suggestions for settings.php - Local dev, Development server, Live server

Basically, one of the greatest questions of all time: What are some ways you're using settings.php in your development/staging workflow? Right now, I have my settings.php file set up like the ...
79
votes
14answers
48k views

Any way to add CSS for a single page/node?

I'm cleaning up my big crazy style sheets (possibly pertinent to a future question) and I'm wondering the best way to add custom CSS to a specific node or page. In particular, my work site's home ...
76
votes
10answers
43k views

How can I change a user's Drupal password?

How can I change a user's Drupal password from the command line with Drush?
76
votes
5answers
31k views

How to take a Drupal site offline using Drush?

How can I take a Drupal site offline using Drush?
74
votes
8answers
9k views

How can I obscure what I am using to run my site?

Is there anything I can do to prevent somebody from knowing my site is using Drupal by looking at the source code of the front page? I am referring to people who scan sites using software that detects ...
71
votes
3answers
11k views

Given that db_select is much slower than db_query, why would I want to use it?

For the background on this, please see http://drupal.org/node/1067802. Given all that, what situations exists where I might want to use db_select(), or should I be relying solely on db_query?
70
votes
4answers
65k views

How do I load a field collection from a node?

I have a node that has a few field collections on it. When I look at node_load() output, I see: [field_rich_text_group] => Array ( [und] => Array ( ...
58
votes
6answers
84k views

How do I create custom regions in a theme?

I want to add a new area which will be site wide. Describe the process of getting this new region into my theme, if possible generalize it for adding any new, custom region.
57
votes
5answers
58k views

How to print the query which is built using db_select()?

I want to print the query which is built using db_select() in a programmatical way. Is there any API function provided by Drupal Abstraction Layer? It is similar to query output in Views, but I want ...
56
votes
7answers
64k views

Rebuild images from image style

I have an image style in Drupal 7. I attached several images to a nodes and display the images based on this style. I then changed the effects on this image style but the existing images are not being ...
56
votes
2answers
20k views

What are Ctools plugin (content type, access, etc), and how does one create them?

What are Ctools plugins, and how does one create them?
56
votes
4answers
35k views

What does “The provided host name is not valid for this server” mean?

I am running a Drupal 8 website, and when I browse to any page, I get a plain white page with just the following error message on it. The provided host name is not valid for this server. What does ...
55
votes
6answers
29k views

How can I automatically upload images on file selection rather than pressing the upload button?

I have a custom content type to allow users to upload images. I'm trying to keep the interface as simple as possible. The content type contains a single image field. This works, but some users don'...
55
votes
9answers
3k views

Real world experience in scaling and tuning performance

The website I'm working is allegedly going to have a massive hit rate soon after launch. The client is talking about the possibility of around 2500 hits per second over a day or so. Ignoring the ...
55
votes
8answers
45k views

How to programmatically create Fields?

How can I approach implementing the following in Drupal 7? What I need to do is create a module which defines a new fieldable entity, called 'Company'. I have a list of, let's say, 20 fields that ...
53
votes
6answers
42k views

“OR” condition in db_select()

I am studying the new database layer, and I am glad it is changed to an OOP layer. I need to implement a query with db_select(). I found I can add a WHERE statement with $query->condition(), but by ...
53
votes
10answers
11k views

How do you improve Drupal performance?

Drupal is fast at develop, but the performance is so poor. It is hard to reach 50 request per second. And there are so many SQL queries in a simple web page. If you test the request time of a form ...
52
votes
13answers
19k views

How do I hide nodes that shouldn't be directly accessed from users and search engines?

I've found that there are times I have a node that simply contains content that will be displayed somewhere else, but shouldn't be viewed directly. That is, no one should ever go to node/1234, but the ...
52
votes
3answers
15k views

Is it possible to replace more than one form element (wrappers) triggered by only one #ajax trigger element?

function ajax_example_simplest($form, &$form_state) { //This is my ajax trigger element $form['element_trigger'] = array( '#type' => 'select', '#options' => array( 'one' =&...
52
votes
3answers
10k views

What's best practice when working with the language[und]?

I'm starting to use this form to access data in my module. (See comment #1.) $node->field_test[$node->language][0]['value'] I thought that looked like a pretty good solution, but further down ...
51
votes
9answers
93k views

How do I access a field value for an entity (e.g. node) object?

node_load((int) $nid) loads a fully-populated node entity. $node->title->value gets the title, but how do I access field values in Drupal 8?
51
votes
2answers
27k views

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?
49
votes
7answers
55k views

How to a use a template file to theme a form?

While nodes, comments, blocks and many other things in Drupal are themed using theme template files (like node.tpl.php), forms are a different story. There are no theme template files for forms. How ...
49
votes
3answers
34k views

Better understanding of Drupal behaviors

I read about Drupal behaviors today, and I tried writing the following code. (function ($) { Drupal.behaviors.mymodule = { attach: function (context, settings) { $('#mymodule_id', ...
48
votes
3answers
31k views

How to upgrade only core with drush?

There's a huge security leak in <7.32. So I want to upgrade all my Drupal sites asap without too much worrying about breaking stuff. But... $ drush dl drupal-7.32 It's forbidden to download ...
48
votes
17answers
120k views

Configuring the temporary directory

I have recently moved a site from a localhost to a VPS. I have managed to make the public and private files writable; however, I am not sure where to find the temporary folder and how to change the ...
47
votes
9answers
55k views

Where does Drupal store the content of a node's body?

In the node table, you'll find everything except the actual body. Where can I find this body text? I'm assuming it's being stored as a blob somewhere.
46
votes
5answers
893 views

For someone who is not a programmer or is starting how can he/she contribute to Drupal.org?

I have been talking to people who are starting in the university about Drupal. But they are beginners in programming. so they told me how they can contribute to Drupal or being more involved. What ...
46
votes
5answers
61k views

How do I get the node ID from the URL?

So far, I came across these 3 functions in Drupal 7, but I am not really sure what the difference between them is, and which is more appropriated to get the node ID in a block preprocess function. ...
46
votes
3answers
18k views

How to migrate from test environment to production environment?

The migration is from the local environment to the production environment. The production environment has run some time and created a lot of articles. In order to add new things to my site, I added ...
45
votes
7answers
37k views

How to change the length of field settings?

I have set once to a website a lenght limit to a field. And now the client wants to put more characters to that field. I cannot change the maximum size from Drupal because I get the following error ...
45
votes
10answers
58k views

Check if a user has a role

How can I check if a user has a certain role? I found this but it is for Drupal 6.
45
votes
5answers
93k views

Nginx vs Apache - Are there any actual usage comparisons and statistcs out there?

I have a new server to play with, and I am staring at a blank canvas. I can put anything I want on it. While I am comfortable with Apache, I keep hearing how nginx can handle so much more traffic than ...
45
votes
5answers
33k views

Create a user programmatically and give they a role

I'm creating a user programmatically like this: $newUser = array( 'name' => $mail, 'pass' => 'password', // note: do not md5 the password 'mail' => $mail, 'status' => 1, '...
44
votes
3answers
27k views

How to provide template for particular view mode?

I want to theme the search result view mode with a template. I had it in my head that naming a template file node--article--search-result.tpl.php would do the trick, but I'm obviously wrong about ...
43
votes
4answers
84k views

Drush command to download AND enable a module

To download and install a module, I run: drush dl module_name drush en module_name -y I put that in a Bash script function, and just call "drin module_name" to simplify. function drin(){ drush dl ...
42
votes
4answers
35k views

How to programmatically send an email?

I'd like to use Drupal's email system to programmatically send an email from my custom module. Is that possible?
41
votes
7answers
65k views

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?
41
votes
11answers
11k views

How can I block an abusive person who endlessly tries to register more accounts?

I have a free site with open registration; anyone can register and I am not able to change that. However, accounts must be approved by an administrator after completing a profile, so I have access to ...
41
votes
11answers
33k views

Views - Add a wrapper DIV around a Group

In Drupal 7, I have created a View that lists several fields. The fields are grouped by another field (the term ID of the field). The mark up looks like this: <h3>[Term 1]</h3> <div ...
41
votes
11answers
28k views

How to display a field before node title?

I'm looking to render a certain field before the node's title when displaying a teaser in D7. Effectively I want to go from this to this. I have looked into updating the node.tpl.php but I notice ...
41
votes
4answers
44k views

How do I get the path for public://

I need to get the path for public:// at runtime. Is there a function I can use to get it?

15 30 50 per page