Questions tagged [7]

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

Filter by
Sorted by
Tagged with
150 votes
10 answers
204k views

What are the recommended directory permissions?

I'm gearing up to deploy a Drupal 7 site and I can't find any documentation. What are the recommended security-conscious permissions for files and directories? I am specifically interested to the ...
user avatar
  • 2,119
109 votes
2 answers
68k 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 ...
user avatar
  • 1,233
106 votes
1 answer
43k 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
9 answers
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 on a Drupal site have a positive affect ...
user avatar
  • 5,414
81 votes
12 answers
54k 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 page ...
user avatar
  • 1,290
77 votes
4 answers
73k 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 ( ...
user avatar
  • 3,653
70 votes
3 answers
12k 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?
user avatar
  • 1,935
63 votes
6 answers
70k 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 ...
user avatar
  • 4,913
61 votes
8 answers
77k 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 ...
user avatar
  • 3,653
58 votes
2 answers
45k 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', ...
user avatar
  • 3,024
56 votes
9 answers
52k 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 ...
user avatar
  • 843
54 votes
10 answers
14k 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 ...
user avatar
  • 655
53 votes
8 answers
50k 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 ...
user avatar
  • 20.6k
53 votes
6 answers
37k 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'...
user avatar
53 votes
19 answers
146k 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 ...
user avatar
50 votes
7 answers
44k 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 ...
user avatar
  • 4,350
49 votes
5 answers
71k 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. ...
user avatar
  • 2,786
49 votes
4 answers
45k 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?
user avatar
49 votes
6 answers
42k views

Programmatically create a user and assign a role

I'm programmatically creating a user with the following code. $newUser = array( 'name' => $mail, 'pass' => 'password', // note: do not md5 the password 'mail' => $mail, 'status' =&...
user avatar
48 votes
3 answers
30k 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 ...
user avatar
  • 3,909
47 votes
4 answers
57k 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?
user avatar
  • 1,973
47 votes
3 answers
19k 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 ...
user avatar
  • 3,788
46 votes
11 answers
71k 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.
user avatar
  • 4,539
45 votes
5 answers
953 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 ...
user avatar
  • 2,230
43 votes
7 answers
44k 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 as ...
user avatar
  • 2,786
42 votes
3 answers
50k 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 ...
user avatar
  • 931
41 votes
9 answers
46k 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 "...
user avatar
41 votes
1 answer
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'] <- ...
user avatar
  • 2,440
41 votes
1 answer
1k 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 ...
user avatar
  • 513
40 votes
9 answers
32k views

Count of nodes by type [closed]

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?
user avatar
  • 565
40 votes
3 answers
60k 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 $...
user avatar
  • 1,973
40 votes
7 answers
14k 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 ...
user avatar
40 votes
3 answers
54k 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 ...
user avatar
  • 1,353
40 votes
1 answer
19k 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 ...
user avatar
  • 6,853
39 votes
11 answers
29k 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 ...
user avatar
  • 635
39 votes
2 answers
31k 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?
user avatar
  • 563
39 votes
4 answers
16k 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 ...
user avatar
37 votes
4 answers
22k 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?
user avatar
  • 6,037
37 votes
4 answers
27k views

What's the proper way to use EntityFieldQuery?

In Drupal 7, the API documentation for node_load_multiple() specifies that using the $conditions parameter has been deprecated in favor of using EntityFieldQuery. In which way should EntityFieldQuery ...
36 votes
6 answers
13k 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 ...
user avatar
  • 163k
36 votes
12 answers
37k 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 ...
user avatar
  • 689
36 votes
6 answers
60k views

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

I need to get the full URL of the currently opened page. I use the following code, but it returns http://localhost/mysite/page_name. $path = isset($_GET['q']) ? $_GET['q'] : '<front>'; $link =...
user avatar
  • 1,795
36 votes
2 answers
26k 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.
user avatar
  • 6,483
36 votes
4 answers
8k 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 ...
user avatar
  • 3,652
36 votes
9 answers
15k 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 ...
user avatar
  • 11.9k
35 votes
5 answers
79k views

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'...
user avatar
  • 501
35 votes
4 answers
18k 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 ...
user avatar
  • 163k
34 votes
2 answers
25k views

How can I update from the recommended release of a module to it development snapshot?

I'm currently using the Geofield module, 7.x-1.0-beta2 (released on November 17, 2011). The development snapshot has some functionalities I want. How do I correctly and safely update to the ...
user avatar
  • 1,723
34 votes
14 answers
11k views

How to move installed modules from /sites/all/modules/* to /sites/all/contrib/modules/*

I have been searching for the answers to this question with no luck at all. From what I observe in the database structure, the location to the modules are specified in the 'system' table. The only ...
user avatar
  • 719
34 votes
5 answers
18k 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?
user avatar
  • 1,072

1
2 3 4 5
530