Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [7]

Version tags should be used only for questions that apply to a version only, not to merely say what version a site is using.

143
votes
11answers
180k 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/ ...
133
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 ...
106
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
39k 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.
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 ...
83
votes
7answers
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 ...
78
votes
14answers
49k 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 ...
71
votes
4answers
66k 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 ( ...
70
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?
58
votes
8answers
66k 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 ...
57
votes
5answers
59k views

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 ...
55
votes
8answers
46k 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 ...
54
votes
6answers
31k 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'...
54
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 ...
53
votes
7answers
43k 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 ...
50
votes
2answers
35k 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
17answers
123k 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 ...
46
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 ...
46
votes
5answers
901 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
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
10answers
60k 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
34k 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, '...
45
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 ...
44
votes
5answers
85k 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
45k 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?
42
votes
4answers
37k 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
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
1answer
6k views

Why is hook_form_alter() so messy?

Here's an example I just ran into. I'm trying to put some HTML in the label of my field. $form['field_feedback']['und']['#title'] <- has the title $form['field_feedback']['und'][0]['#title'] <- ...
41
votes
7answers
39k views

How do I programmatically log in a user?

I am looking for the API that will let me login a user by passing it the username and password. Does anyone have experience with this? To clarify, I am trying to make an AJAX login box that appears ...
41
votes
1answer
974 views

I need to bring a site to version control, and set up the continuous Integration environment

I am an entrepreneur with a Drupal 6x project that started small enough to not need version control (per developers), but now I am convinced there is no way without it. There's extensive documentation ...
40
votes
7answers
13k views

Drupal SA-CORE-2014-005 - How to tell if my server / sites were compromised?

I just updated all my sites using the patch method of resolving the Drupal SA-CORE-2014-005 exploit. I just read reports that just yesterday there is someone from a Russian IP infiltrating drupal ...
39
votes
9answers
28k views

Count of nodes by type

I am looking for a snippet that lets me display the total count for a specific node type, e.g. "Pages = 167" or "Products = 10630." What code should I use to achieve this?
39
votes
3answers
51k views

How do I customize the search result page?

I have customized the teaser view of my content types and the page view. Now I need to use the teaser view for the search results page. By default, Drupal displays a full text jumbled mess for each ...
39
votes
1answer
18k views

Managed file: the file used in the field may not be referenced

I am having some issues with the managed_file type. Whenever I try to edit and save a form that has a managed_file element in it an error occurs: The file used in the Picture field may not be ...
38
votes
9answers
42k views

How do I change a theme based on the URL?

I have a Drupal instance running on example.org. Which has a theme X installed and activated. Now for a limited period an event is supposed to be held on the site for which a special section has been "...
37
votes
4answers
15k views

What is the difference between the Workbench and Workflow modules?

I use the Revisioning module to manage revisions of nodes on my Drupal 7 site. I had been updating the site by myself, so Revisioning was sufficient; now, however, I will be adding some content ...
36
votes
3answers
54k views

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 $...
36
votes
2answers
23k views

Difference between Minimum cache lifetime and Expiration of cached pages

On Drupal Performance Page, under the fieldset Cache you have two options. One is Minimum Cache Lifetime and the other is Expiration of cached pages. What is the difference between these two.
36
votes
4answers
20k views

What is the template suggestion for node 'teaser' view mode?

node--[type|nodeid].tpl.php targets to node's default view mode. However I want to override the template for teaser view mode. What is the template suggestion (.tpl.php file) for 'teaser' view mode?
36
votes
4answers
23k views

What's the proper use of EntityFieldQuery?

In Drupal 7, the API documentation for node_load_multiple() specifies using the $conditions parameter has been deprecated in favor of using EntityFieldQuery. How does one use the class to generate a ...
36
votes
9answers
13k views

How to create a union of two views?

I'm trying to get a union of a user's nodes and comments sorted by "post date". This post links to sandbox projects for D6 but there is nothing for 7. This post has an example of using ...
35
votes
4answers
17k views

How do I change the ajax loading behaviour in Views?

I have a view with some exposed filters in a block; it uses AJAX and the auto-submit feature so the view is re-loaded as soon as a filter option is changed. In the short delay between selecting an ...
35
votes
3answers
41k views

how to send variable from .php file to .js file?

I hope someone is able to help me. The problem is the following one: 1)I have module in which a assign the variable in order to send to the template file php.tpl <?php ... $testvar="Hello from ...
35
votes
6answers
12k views

How do I avoid checking for updates for a specific module?

In a current project I have had to patch the life out of a few modules (node hierarchy, workbench access and a few more). These modules are now absolutely perfect for the project's needs and are very ...
35
votes
2answers
23k views

How to switch from recommended release of module to dev release?

For example, I'm currently using the Geofield module. I'm using version: 7.x-1.0-beta2 (2011-Nov-17) Now I see the development version has some functionality that I want. How do I correctly and ...
35
votes
3answers
22k views

Using IN clause in db_query

I can't figure out how to add an IN clause in my query, using placeholders. I'd want it to be something like: $nids = array(1, 2, 3); $result = db_query('SELECT * FROM {node} WHERE nid IN :nids', ...
35
votes
5answers
16k views

Bulk field update?

I added a new (text) field to a Drupal 7 content type that already has many nodes. How can I fill the field with a default value for all these nodes?
35
votes
1answer
28k views

How to get a node by its url alias?

I know I can load a node by its title with the node_load() function. Is it possible to load a node by its URL alias?
35
votes
4answers
6k views

How do I debug permissions?

How do I debug permissions in Drupal 7? I use core reporting, error logs, devel module error logs, backtrace and node access permission block but sometimes it is not enough. What else should I check ...
34
votes
11answers
33k views

Get all users with specific roles using EntityFieldQuery

I thought this was an easy task, yet there does not seem to be a Drupal-method for this. I came as far as knowing I have to use EntityFieldQuery for this - because the API said conditions for ...