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
19
votes
11answers
12k views

How to tell if a site is using Drupal 7

I know how to check if a site is built with Drupal, but is there a way to tell if a site is built with Drupal 7?
19
votes
3answers
11k views

Multiple Values to Trigger #states

How can I have multiple values trigger the Form API's #states? Say for example, I wanted this field to be visible not only if the value is 5 (currently works below), but wanted to make the field ...
19
votes
3answers
16k views

Embed a “node add” form in a page

I'm looking for a way to embed a "node add" form on a landing page. I was using Form Block, but it appears to bring many error because I was using a development snapshot version.
19
votes
7answers
13k views

fast saving single field value

I've got around 70k nodes of specified type on my site. I need to run an update on them. Some operations and setting one field to desired value. node_save is really slow and it causes crashes (too ...
19
votes
3answers
30k views

Passing arguments to drupal_get_form()

How can I pass arguments to drupal_get_form() in Drupal 7? function new_menu_callback() { $vars = some_example_function(); // returns: array(1 => 'one', 2 => 'two'); $output = $vars[2]; $...
19
votes
4answers
44k views

How to edit <head> info

In Drupal 6 the entire page data was stored in page.tpl.php. Now, with Drupal 7, only the content that appears in between <body> and </body>. So how do you edit the HEAD info? Is it still ...
19
votes
1answer
8k views

Saving a field of type 'text_format' as a system setting variable

I'm attempting to give my content editors the ability to change a variable for a custom module. This variable can have html. I don't want to require them to have any knowledge of HTML, so I want to ...
19
votes
4answers
21k views

Get only some fields with EntityFieldQuery?

Drupal 7 has very promising ORM-like system of queries with EntityFieldQuery. Currently, I understand how to make selection of nodes, but the result doesn't contain any specific information, like ...
19
votes
3answers
18k views

Form Redirect not working if 'destination' is in URL

In one of my forms, I'm trying to set a $form_state['redirect'] so the form will go to that destination after the user clicks one of the action buttons. If I inspect $form_state['redirect'] both ...
19
votes
2answers
15k views

Using views with a custom table/schema

I need to set up some views that will pull some data from a custom table I created. Some views will need to pull content the regular way and from my custom table (where I may query for a particular ...
19
votes
3answers
15k views

How to change a field value with a Rules Action?

I'm trying to set up a Rules Action that can change the value of a field. I created an Action Set with a data type of Node. When I go to create a Rules Action, I have access to every default Drupal ...
19
votes
3answers
14k views

How to hide a custom user field in user profile?

In Drupal 7, what is the best way to prevent any non-administrative user from changing a custom user profile field? Use case: I've created a user field called "Customer ID" that I do not want the ...
19
votes
6answers
25k views

How to programmatically add image from external URL using media module?

I want to programmatically add an image from an external URL and have the module store and display a local copy of the image. How can I do that? Normally, I would click the "select media" button while ...
19
votes
3answers
8k views

Best practice for building modules using classes

I'm looking to start building my modules as classes now that lazy/auto-load are in Drupal 7, and I'd love to look at some modules (contrib or core) that are doing a great job of it. Is there a ...
19
votes
4answers
13k views

Programmatically creating an order in Drupal Commerce for anonymous users redirecting to payment page

Ryan has some great code that you can programmatically create an order <?php global $user; $product_id = 1; // Create the new order in checkout; you might also check first to // see if your user ...
19
votes
4answers
3k views

Best practices for page layouts

I'm trying to figure out what the best practices are for page layouts in Drupal. Many pages have several different elements on them like main content, a header image, etc. I'm not looking at ...
18
votes
10answers
26k views

What are my alternatives to disable update notifications but without using module Update Notifications Disable?

I need to disable the update notification overall Drupal 7, rather than downloading the module Update Notifications Disable because it caused a fatal error, and the site went down. Is there any other ...
18
votes
9answers
45k views

Create template file for views block

There is a lot about theming custom blocks, but what about blocks created by views? My views block has id: block-views-posts-listing-block, I try many ways for naming template file, ex: block--block-...
18
votes
3answers
24k views

How do I find the role id from role name?

On log in I want to check a third party data source (table in the db) for a user, and if found I want to add a role to that user. I don't want to guess the rid of the role, I want to get it from the ...
18
votes
7answers
26k views

Add FILTER CRITERIA in Views Programmatically

I want to add/modify a filter criteria programmatically. For example, for a view, I added an "Email Address" filter whose value is needed to change dynamically, it is needed to set to the current ...
18
votes
5answers
13k views

Why can't I delete certain content types?

I have a Drupal 7 site, and under the Content Types menu, only certain types have a 'delete' link under the 'Operations' column. All of the content types have the links for 'edit', 'manage fields', ...
18
votes
3answers
22k views

How to check if (unmanaged) file exists?

I can't find a Drupal API function in D7 that tells me if an (unmanaged) file exists. D6 had a file_check_location but not for 7. How to check if (unmanaged) file exists?
18
votes
4answers
17k views

How do I remove the “submitted by” text on node display?

In Drupal 6 the option to remove that text was located in the theme settings; where is it in Drupal 7?
18
votes
4answers
9k views

How do I programmatically install and enable a module?

There is a lot resource for doing it in Drupal 6, but I didn't find a solution for Drupal 7. How can I install and enable selected modules?
18
votes
4answers
10k views

How can I detect if the current viewed page is administrative?

How do I detect whether the user the page is currently viewing, is considered administrative? An administrative page can be recognized when the administration theme is activated. In my case I would ...
18
votes
3answers
24k views

Filtering on node whose user ID is equal to the current user

In Drupal 6 you can have a filter node.uid = current user. How do you do this in Drupal 7?
18
votes
5answers
49k views

render or print image in a drupal 7 node.tpl?

I am trying to theme a node with tpl and when i tried to print image , I cant find image path like in d6.. which function i have to call to properly output image .. I mean something like theme('')? ...
18
votes
6answers
16k views

Hide errors from users but show to admin?

Under 'Error messages to display' I can hide errors (as is recommended for production sites). However is it possible to hide errors for everyone except a certain role?
18
votes
2answers
12k views

How to prevent user registration

I'm getting a couple of user registrations on my personal website (presumably from bots or people trying to hack my site). How do I disable new user registration entirely?
18
votes
6answers
25k views

How do I display/edit the machine name for a View?

How do I display/edit the machine name for a View? Reason for asking is that I tried cloning a view but the name I gave was rejected because it had already been used but I couldn't see where.
18
votes
1answer
22k views

Install and Configure XHProf (Ubuntu)

Problem I'm trying to use XHProf but I'm getting horrible php error every time it runs. Warning: Invalid argument supplied for foreach() in xhprof_compute_inclusive_times() (line 1670 of /var/www/...
18
votes
3answers
8k views

Is there anywhere a good writeup on Drupal directory structure?

I wonder if there is a good writeup on Drupal directory structure?
18
votes
1answer
14k views

Joins and looking for NULL values

I'm using the flag module to let users mark their questions as solved, similar to how it works on this site. I therefore want to let users filter posts to show only unsolved questions. Additionally, ...
18
votes
1answer
18k views

Make 'Full HTML' the default text format

How do I make Full HTML the default text format for the administrator? Currently it is Filtered HTML.
18
votes
2answers
29k views

Do you have an example of hook_menu() access callback?

I have downloaded the examples project, but in the menu_example module all the access callback are set to true.. hard to understand how it works. In my example, my meno entry should be visible on ...
18
votes
4answers
9k views

EntityFieldQuery vs Db_select()

Why should I use EntityFieldQuery when I can do the same work with Db_select() to fetch the value. It would be better if someone can provide an example, not only a link.
18
votes
2answers
4k views

Views Block's machine name is being “hashed” (?)

A Drupal newbie, so correct me if my understand is wrong, but normally, when a Block is created by Views, the machine name of the block is appended to the Views' machine name. i.e. "...
18
votes
3answers
22k views

How to get rid of Deadlocks and Lock time out type issues?

I read multiple blogs, tried to google, it but didn't find any satisfaction from any solution. I have the following issues : PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found ...
18
votes
3answers
23k views

What hook can I use for post-save actions?

I've found several posts with this same question, but the answers always diverge to some other topic or they don't work for my needs. After a node is saved, I want my custom module to insert a row ...
18
votes
5answers
6k views

Is it possible to force your module's update hook to run?

I am the author of the Date iCal module, and the new major version I'm working on (3.x) requires a two-part schema update for users who had 2.x installed. I've written the update hook that makes these ...
18
votes
7answers
22k views

How do I show content in an overlay?

I want to display some content, returned from an AJAX call in an overlay or popup. Do you have any idea on how I can do it?
18
votes
2answers
12k views

Using LIKE in db_query in D7

I have a query like this in Drupal 6: $sql = 'SELECT sid, score FROM search_index WHERE word LIKE "%%%s%%"'; $result = db_query($sql,$search_term); And it worked fine, but now I'm upgrading to ...
18
votes
2answers
3k views

Drupal Commerce. Trigger shipping rules based on product field value

I'm really losing the will to live and hope somebody can help me. I want to trigger a 'free shipping' rule based on a product field value, but for the life of me can not expose the free shipping ...
18
votes
1answer
734 views

Technical advantages of either Configuration or Features over the other?

In short, Configuration vs Features, in Drupal 7, fight! As always, technical advantages, or other hard facts, as we don't do discussions here. Drupal 7 specific to limit to scope, as CMI vs Features ...
17
votes
4answers
37k views

Check if a field is empty

How to you check that a field is empty, when you have the $node object?. I found this as possible solution: $field = field_get_items('node', $node, 'field_post_image'); I can check now: UPDATE.Ups!...
17
votes
4answers
249 views

How do I choose which module to use when there are several options for the same functionality?

It's not at all uncommon to find multiple modules that provide basically the same functionality. For instance, there are many SPAM control modules that offer extremely similar functionality (e.g., ...
17
votes
4answers
20k views

How to set a taxonomy term programmatically for a node?

I created taxonomy terms and assigned it to a content type 'Article' using term reference field. I created nodes by programmatically but how to set taxonomy terms for the nodes? The taxonomy terms ...
17
votes
5answers
9k views

How to programmatically list member entities of an Organic Group?

How can I programmatically get a list of member entities of an Organic Group? (I know how to get a list of group members using Views — I'd prefer to do this using the Organic Groups API, but haven't ...
17
votes
2answers
11k views

How can I detect when a node is changed from 'Published' to 'Unpublished'?

In hook_node_update(), I can easily tell the 'status' of a node (whether it's published or not) after it's been updated. However, is there an easy way to check to see if the updated node was ...
17
votes
5answers
16k views

How I can delete all node/field revisions?

I have a drupal 7 sites, where it keeps node and field revisions. I keep revisions for the case where by mistake a new faulty version is saved and I want to revert back. But, now I want to clean and ...