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.
26,479
questions
153
votes
10
answers
212k
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 ...
111
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 ...
108
votes
1
answer
44k
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.
93
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 ...
81
votes
12
answers
55k
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 ...
78
votes
4
answers
74k
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
(
...
71
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?
64
votes
7
answers
72k
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 ...
62
votes
8
answers
81k
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 ...
59
votes
2
answers
46k
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', ...
57
votes
9
answers
53k
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
19
answers
152k
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 ...
53
votes
8
answers
51k
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
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'...
51
votes
6
answers
43k
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' =&...
50
votes
7
answers
45k
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 ...
50
votes
5
answers
73k
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.
...
50
votes
4
answers
47k
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?
49
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 ...
48
votes
8
answers
74k
views
Check if a user has a role
How can I check if a user has a certain role?
48
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 ...
47
votes
4
answers
58k
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?
45
votes
5
answers
965
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 ...
44
votes
7
answers
45k
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 ...
43
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 "...
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 ...
42
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 ...
41
votes
3
answers
61k
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 $...
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'] <- ...
41
votes
3
answers
55k
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 ...
41
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 ...
40
votes
9
answers
33k
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?
40
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 ...
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 ...
40
votes
2
answers
32k
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?
39
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?
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 ...
38
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 ...
37
votes
5
answers
83k
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'...
37
votes
6
answers
67k
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 =...
37
votes
4
answers
28k
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
14k
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 ...
36
votes
12
answers
38k
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 ...
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.
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 ...
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 ...
35
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?
35
votes
2
answers
63k
views
Custom validation for a form?
I need to add custom validation to a form, lets says add article form.
I was expecting something like hook_FORM_ID_validate() to handle this, but cannot find anything relavant in the API ...
34
votes
5
answers
33k
views
Node count for taxonomy terms
How can I display the node count values for taxonomy terms with sorting the result list in descending order of node count?
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 ...