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
20
votes
1answer
4k views

How to get taxonomy synonyms working robustly with Search API?

Tag synonyms are a popular, important feature in many sites (used here on StackExchange, for example), and taxonomy synonyms used to be part of Drupal 6's core Taxonomy module, before being dropped in ...
19
votes
7answers
22k views

How to copy content type?

How to copy content type in Drupal 7 ? I can't find a button to duplicate content type.
19
votes
3answers
9k views

How does the batch API work internally?

I ran into a timeout issue using migrate the other day and started to wonder how the Batch API works internally. The way I understand it is that in its simplest form you'll pass an array of values (...
19
votes
7answers
28k 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 ...
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
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
3answers
25k 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?
19
votes
7answers
14k 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
45k 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
5answers
9k views

reseting the hook_update_n status of a module

I'm extending a module I've previously written and it needs some schema changes which I implement in hook_update_N. I've updated the module's version from 7.x-1.0 to 7.x-1.1 and implemented the ...
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
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
26k 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
14k 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
27k 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
25k 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
5answers
14k 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
23k 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
10k 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
11k 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
5answers
50k 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
17k 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
4answers
21k 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 ...
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
4answers
11k views

How to logout all active users?

Instead of putting my site in "maintenance mode" I would like to put it in a complete "readonly mode". There is a module for that, however, it only prevents "node add and edit". I would like to ...
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
19k 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
23k 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
24k 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
7k 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
6answers
19k views

How can I run PHP code without writing a module?

I need to attach a field to some bundles. A PHP snippet will do the job for me, so I don't need a module.The below snippet is what must be executed : $field_name = 'field_custom_image'; // Create the ...
17
votes
9answers
8k views

Is there a way to hook on cache clearing?

For a big institution website, with heavy caches, I'd like to generate caches as soon as possible, so that no user may arrive on cache generation... I have a cron set all minutes that does it, by ...
17
votes
4answers
39k 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
250 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., ...