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
33
votes
5answers
68k 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'...
33
votes
3answers
21k views

How do I group elements in a view?

I have 8 articles: Article 1 (Gaming), Article 2 (Local News), Article 3 (World News), Article 4 (World News), Article 5 (Gaming), Article 6, Article 7, Article 8. In a view I would like to group the ...
32
votes
18answers
38k views

How to hide Input Format Options and help text under a textarea?

How to hide Input Format Options and help text under a textarea when adding|editing a node?
32
votes
5answers
51k 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 =...
32
votes
4answers
49k views

How to use drupal_mail() to send emails with custom template

I would like to use the drupal_mail() function to send out emails but with a custom HTML template so that they are in keeping with my website design but I am a complete newbie to hooks and modules etc....
32
votes
7answers
115k views

How do I silence PHP errors?

Is there a way to silence all PHP errors, warnings and notices in Drupal? They are usefull on the devel site but they are a big security risk, and make the site look bad on live. I know on Drupal 6 ...
32
votes
5answers
14k views

Do I need a cron task for processing a queue?

I've got a task that takes about 45 minutes to complete and needs to happen every day (synching users to several external database, etc). To handle the work, I've set up a cron queue with ...
31
votes
8answers
45k views

How do I programmatically show a view block?

I created a view block, whose machine name is "news." How do I display it using module_invoke() and the machine name of the view?
31
votes
5answers
31k views

Views and node count for taxonomy terms

How can I display the node count values for taxonomy terms in Views? with sorting the result list in descending order of node count.
31
votes
13answers
22k views

How can I disable a single checkbox in a 'checkboxes' FAPI element?

Title basically says it all, I want to disable a single checkbox of a checkboxes type FAPI element. I don't want to do if with JavaScript, nor is changing it from checkboxes to multiple checkbox ...
31
votes
3answers
12k views

Differences between value and safe_value

What are the differences between ['value'] and ['safe_value']?
30
votes
9answers
44k views

How do I remove duplicates when using the random sort?

I have created a view where I am displaying the the node title and a logo (a cck field). In the arguments I have passed the taxonomy term name. In the result a node is displaying 2 or 3 times; I ...
30
votes
7answers
23k views

Excluding empty(Null) fields when using EntityFieldQuery query condition

Is it possible to select all of the entities who's xyz field is empty? I tried soemthing like this: ->fieldCondition('field_name', 'value', NULL, 'IS NOT NULL'); However, this doesn't seem to ...
30
votes
5answers
27k views

Best practice for language key for “und” in hook_form_alter

I'm modifying in a form in my custom module. Code looks like: function my_module_form_alter(&$form, &$form_state, $form_id) { if ($form_id == "someID") { $form['...
30
votes
8answers
18k views

How to make a form required with states?

I have a drop down list that displays various fields based on what is chosen and I know that I can toogle the visibility with states but when I try to use required the * span is display but it isn't ...
30
votes
2answers
33k views

Eliminate render-blocking JavaScript and CSS in above-the-fold content

I am building a Drupal 7 site. These are some of the modules I use: Adaptivetheme (theme), Views and Content Panes, Panels, Mini panels, Panels everywhere, Page manager, Superfish for menus, Addthis, ...
30
votes
2answers
13k views

PHP 5.4 and Drupal 7

I have heard that PHP 5.4 is faster than PHP 5.3. Would it be ok for Drupal 7 to run under 5.4, or various contributed modules may start to break the site? Anyway, If I use APC opcode cache, maybe 5....
29
votes
2answers
56k 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 ...
29
votes
3answers
38k views

Count results in Views using aggregation [closed]

Is it possible to count results (e.g. count the nodes of the content type x) in a view, using aggregation (not programmatically)?
29
votes
5answers
55k views

Dynamic select list in the form (dependent dropdown)

I'm using Drupal seven. I want to make the options in a select list be dependent on the value chosen in another select list in a form. I'm sure this has been asked many times before, but I am having ...
29
votes
4answers
4k views

Memory-saving cache-clearing strategies for large sites?

One of my Drupal 7 sites has thousands of fields, a bunch of content types, more than 25 views, and hundreds (soon to be thousands) of profile types. Because of this, I'm using a core patch that ...
29
votes
2answers
8k views

Programmatical use of Search API

Problem: Need to run my own searches programmatically with Search API. Every google result I find is geared toward teaching non-developers how to use the module with Views with no results on doing it ...
28
votes
2answers
24k views

How to create test_endpoint?

I am new to drupal and I am using services module for using REST and RESTWS module. I used RESTWS and could get the content of the node by http://base_url/node/1.xml and now I need to add a node ...
28
votes
7answers
22k views

drush updatedb for a single module

Is it possible to perform a single module's update function via drush? I can see drush updatedb which does not take an modulename as argument and runs all available updates. Then there is drush pm-...
28
votes
2answers
20k views

What is the meaning of the field:delta content type offered in contextual filters in views?

When creating a new contextual filter for a view the list of types includes options such as content:spec (field_spec:delta) where spec is the name of a field I have attached to the content type ...
28
votes
5answers
21k views

How do I override a taxonomy/term/% list with a view?

I have a vocabulary attached to a content type. Only one term can be selected to categorize a node made with this content type. The vocabulary is called Vehicles and has terms 'cars, trucks, boats.' ...
27
votes
8answers
78k views

How do I get only one result using db_query()

I am transitioning from 'old school' PHP MySQL methods of using mysql_fetch_array(), etc. and I am trying to be more Drupally by using the Database API in my modules. I simply want to return and ...
27
votes
4answers
23k views

How can I insert search box in page.tpl?

How can I insert search box(search block) in my theme programmatically?
27
votes
2answers
24k views

How do I set allowed extensions for a managed_file form field?

Not having any luck find this in Drupal documentation or developer examples. I need to set a managed_file form field to only allow zip files in a Drupal 7 custom module.
27
votes
6answers
30k views

How to add module to admin/config page?

I'm working on a module in Drupal 7. I've added a hook_menu implementation: $items['admin/config/content/mymodule'] = [ 'title' => 'MyModule', 'description' => 'Configure ...
26
votes
7answers
46k views

How to programmatically trigger a click on an AJAX enabled form submit button?

I'm trying to programmatically (with jQuery) trigger a click on button with AJAX behavior in a Drupal form, but so far jQuery('#edit-submit').click() doesn't do anything. A real mouse click on that ...
26
votes
2answers
47k views

List all terms from a vocabulary

I have a taxonomy called services and want to list out all the terms. I can load the vocab with $vocabulary = taxonomy_vocabulary_machine_name_load('Services') but cannot seen to get all the terms ...
26
votes
6answers
15k views

Debug EntityFieldQuery?

I have a module which is misbehaving. An EFQ is returing unexpected results, but I can't see why just by looking at the code. Is there a dpq() equivalent for EFQs? Other ways of debugging them?
26
votes
5answers
34k views

How do I use “NOT IN” in a query?

What is the proper way to write a query containing 'NOT IN' using a condition statement? My query is the following one: SELECT DISTINCT nid FROM node WHERE language NOT IN (SELECT language ...
26
votes
4answers
30k views

How to theme a custom block

I've created a block using hook_block_info and hook_block_theme and the like. But how can I theme it? I have it working to return an array with the keys 'subject' and 'content'. But I created the ...
26
votes
5answers
10k views

Node translation vs. Entity (field) translation

I would like to know what you guys recommend for a multilanguage site. For example, consider the following case: A page and its content should be available in 3 languages (e.g. German, English, and ...
25
votes
4answers
28k views

How to completely turn off caching?

I am developing a site in Drupal 7 and caching slows my work significantly. For example, I had a theming function for a form. I was puzzled, why doesn't it work. Until I cleared the cache and it was ...
25
votes
3answers
17k views

How to assign permissions to roles programmatically?

I have some permissions that I would like to assign to some roles programmatically for easier installation. Because I'm installing the module and creating both permission and roles, I don't have the ...
25
votes
6answers
26k views

Programmatically attaching files

I have created the "Gallery" content type, and added two fields: "photo," and "document." I then used the following code for uploading a file in the "document" field: $file = file_save_upload('...
25
votes
5answers
35k views

How to send HTML email

I am creating a simple module which will be sending HTML emails to users for deals in our website. I have searched a lot, but I can't find a solution proper solution for Drupal. Now I can send mails ...
25
votes
1answer
6k views

Why does Drupal 7 prefer CSS @import rules to <link> tags?

"Don’t use @import," lots of guys say. There are lots of shortcomings of using @import. Using @import within a stylesheet adds one more roundtrip to the overall download time of the page. Using @...
24
votes
6answers
21k views

Using built in jQuery UI in my theme

Every page of my theme will need to use jquery UI. I know it's included with Drupal 7, but I can't really decipher Drupal's way-too-technical documentation. It looks like the only way to do it is ...
24
votes
5answers
22k views

Preprocess function per content type

I have a couple of content types which I need to preprocess in different ways. So template.php in my theme foo currently looks like: function foo_preprocess_node(&$variables) { if ('news' ==$...
24
votes
5answers
15k views

Expose single filter of combination of two fields in views

I have two user profile fields "Last Name" and "First Name". I also have a user list views. I want to expose "Name" as filter which can search for both Last Name and First Name. How can I do single ...
24
votes
5answers
18k views

How to set value of file field with entity_metadata_wrapper

How do you set the value of a file field when using the entity_metadata_wrapper? I've tried doing this in code: $file = new stdClass(); $file->uid = 1; $file->uri = $file_path; $file->...
24
votes
4answers
18k views

How to configure Node Export to mass node export?

I'm trying out Node Export for mass node export, but it seems that I have to choose every node to export individually. What if I want to export all nodes of a selected content type? Is there any way ...
23
votes
9answers
36k views

dpm() does not display any results on screen

I have the same problem as file_scan_directory() takes about 10 seconds to execute. I just tried the dpm(func_get_args()) suggestion, and unfortunately it doesn't show anything to me. I've cleared ...
23
votes
7answers
61k views

How do I clear cache using an SQL query?

After a module update, my site has become unusable, and only shows a php error message. I tried circumventing the problem with drush cc, but that didn't help. Also tried with a custom php script but ...
23
votes
4answers
10k views

Are views cached through the core caching mechanisms or should I be setting the caching directly in each view?

I see there are cache settings in each of my views. Do I need to set these or does the core caching mechanisms in /admin/config/development/performance automatically do some of this and these "extra ...
23
votes
7answers
15k views

Where do I find the vocabulary ID ($vid)?

In Drupal 6 I would go to the taxonomy section of my /admin and I'd be able to find the $vid (numerical) in the URL. In Drupal 7 (no doubt due to the introduction of terms as entities) the URL is no ...