As of May 31, 2023, we have updated our Code of Conduct.

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
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 $...
vintorg's user avatar
  • 1,983
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?
Diane's user avatar
  • 565
21 votes
3 answers
16k views

How do I create a multisite with shared users and nodes? [closed]

I want to create a multisite with Drupal 7: Every site works separately but users, and nodes must be shared among the sites. How do I achieve it?
user avatar
20 votes
4 answers
11k views

Relation vs. References vs. Entity Reference for managing node-reference-type relationships

References Entity Reference Relation It seems like there are several active modules that all have similar functionality. Can anyone offer any information as to which branch appears to be the most ...
starsinmypockets's user avatar
11 votes
10 answers
7k views

How do I enable comments for user profiles?

With users being entities in D7 I assumed the user type would would have built in "comment" option. That doesn't seem to be the case. I just want to allow users to leave comments on the user profile ...
uwe's user avatar
  • 12k
10 votes
6 answers
7k views

Drush installed and running; No Drupal site found even with uri specified

After much trial and tribulation, I thought I had drush all ready to roar. Much excitement. But then, no joy... Drush is working. The sites operate fine via MAMP. Regardless, a "drush cc all" command ...
jenpasch's user avatar
  • 111
8 votes
3 answers
6k views

Show node IDs along with titles in Entity reference Autocomplete list

I'll like to add this functionality to the autocomplete widget in Entityreference field to show node ID next to the titles in the dropdown list. The reason behind the idea is to differentiate between ...
neemu's user avatar
  • 81
5 votes
6 answers
6k views

How to add a custom icon or symbol to a flag link?

I'm working on a 'sample request' implementation for a commerce site using Flag, Views, sessions and a little custom code. I'd like to add an icon or a symbol to let people know that an item they are ...
nizz0k's user avatar
  • 1,172
5 votes
3 answers
11k views

Change menu link title dynamically?

I'm trying to alter the text of a menu item dynamically based upon certain variables. I'm using hook_menu_alter like this: function mymodule_menu_alter(&$items) { $items['toggle-review-process'...
Joren's user avatar
  • 2,440
4 votes
3 answers
678 views

How to prevent access to Views-only content?

When I'm developing sites in Drupal, I create various content types and taxonomy vocabularies that I use with Views to build displays. I might not ever want the nodes to be viewable in their own right ...
pushka's user avatar
  • 1,853
4 votes
1 answer
7k views

Extracting URI value from Image in Views - Getting Index Error

I am trying to create a custom slideshow using Views. Please not that I am not using the Views Slideshow Module What I need to accomplish is to wrap the the relative URL for the images within a ...
Allan's user avatar
  • 553
3 votes
1 answer
858 views

"Allowed memory size" errors on common tasks [duplicate]

I get this error all the time when I'm doing common admin tasks, such as enabling modules. PHP Fatal error: Allowed memory size of 33554432 bytes exhausted How can I fix this?
Yarin's user avatar
  • 287
3 votes
5 answers
3k views

How to bulk update select list fields?

I have a content type and it has a select list field. There are two options Yes or No and this field is not a required field. The website has about 100,000 nodes and I want to bulk update all nodes ...
herci's user avatar
  • 2,140
2 votes
1 answer
738 views

How to access commerce_product field of line-items using Rules to flag the Commerce Product?

Related to this question: How to mark product if it has already been purchased by current user? I have a Drupal Commerce shop, where I'm trying to use the Flag module to mark products to inform users ...
Nenotek's user avatar
  • 47
2 votes
2 answers
845 views

How to implement a follow author (or user) function? [closed]

Is it possible to implement a Follow button for authors of posts in Drupal 7, so that users can: Follow any one they wish, and Be notified about the new posts of those authors. This sounds like '...
rakibtg's user avatar
  • 1,314
1 vote
1 answer
950 views

How to make content translation available for front page?

On my front page I have a language selector (English / French). The default language is French. The translation works only in the content of page (in the views) i want make the translation work in the ...
SeifBh's user avatar
  • 73
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?
Chris Cohen's user avatar
  • 1,945
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. ...
silkAdmin's user avatar
  • 2,814
49 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?
Naoise Golden's user avatar
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 ...
Clive's user avatar
  • 165k
30 votes
5 answers
28k 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['...
Shafiul's user avatar
  • 1,226
24 votes
5 answers
19k 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->...
Smos's user avatar
  • 647
23 votes
2 answers
4k views

What are "#" properties?

While reading the Ajax framework documentation I came across mention of the #ajax property. I know from poking through the code that there are others of these properties with hash signs in front of ...
beth's user avatar
  • 9,087
20 votes
4 answers
32k views

How do I add additional view modes for a node?

I am creating a custom content type. By default, nodes support only two view modes (full and teaser): function mymodule_view($node, $view_mode) { if ($view_mode == 'full') { $node->...
werqious's user avatar
  • 750
15 votes
2 answers
21k views

Form within a block

I'm using drupal_get_form('event_signup_form') to embed my custom form inside a block. The form is being rendered as intended, but submitting the form triggers nothing. The form function itself is ...
kristian nissen's user avatar
10 votes
4 answers
19k views

Autofilling fields based on another field

I have a very complex situation where I need some advice. I have a content type my_content, which has a field collection field attached to it field_mycollection, which has an entity reference field ...
Елин Й.'s user avatar
  • 7,260
10 votes
4 answers
33k views

How do I render a field value including its format?

I'm reading a field value and its format from the database. How would I render that value with the format?
SomethingOn's user avatar
  • 1,281
9 votes
3 answers
21k views

What is the purpose of Views "Attachment", "Content pane" & "Context"?

I've just made a Views for a content type. In one views, I need a page for the content type and a preview of 4 newest posts on the front page. Page is not the problem. For front page preview, I just ...
apasajja's user avatar
  • 389
8 votes
3 answers
10k views

Can I use ajax to target multiple form elements from one input?

I'm trying to use ajax to update two different parts of a drupal form from just one form input blur. I have the standard ajax stuff on my input: $my_form['my_input']['#ajax'] = array( 'callback' =&...
Rick's user avatar
  • 471
6 votes
2 answers
9k views

Change templates based on path alias

What is the easiest way to select a template based on path alias. For example, if I have the following URLs: http://www.example.com/mydirectory/page1 http://www.example.com/mydirectory/page2 http://...
Jane's user avatar
  • 1,795
6 votes
7 answers
24k views

How can I enable clean URLs?

I installed Drupal 7 on Wamp Server. I can't find any checkbox or link to enable clean URLs; I see only the Run the Clean URL Test button. How can I enable clean URLs?
sjkon's user avatar
  • 217
6 votes
2 answers
7k views

EntityFieldQuery display pager

How do I display pager using EntityFieldQuery for fetch results? I can't find complete example. I am doing simmilar to: Sortable, paged table retrieved using EntityFieldQuery But I miss part to ...
NenadP's user avatar
  • 1,507
4 votes
2 answers
3k views

Alter a Views query to use "OR" through the user interface

I have a view with a few different displays, each of them with slightly overridden filters, like this one used in a panel. How do you add this pseudocode via the UI? AND (node.type='story' OR node....
enjoylife's user avatar
  • 3,778
3 votes
2 answers
7k views

Date popup form field doesn't show the default value correctly

I am creating a custom form with "date_popup" form fields. The only issue I have is that the default_value for the date popup form field shows only the first digit of the year, not the whole date. ...
swindler's user avatar
  • 141
3 votes
2 answers
5k views

How to show the count of members that belong to a group?

I have a view showing a list of nodes of type group. How do I set it up to show the count of members that belong to each group?
uwe's user avatar
  • 12k
2 votes
3 answers
752 views

How to check whether one's current User Points are negative with the Rules module?

My question is pretty straightforward: how can I check whether a user's current amount of User Points is negative with the Rules module? I'd like to create an action that should be activated when the ...
Jeroen's user avatar
  • 2,518
2 votes
2 answers
2k views

How to fix entity property X doesn't support writing, when setting content type field values?

I've got a D7 content type with a few fields; nothing particularly special. I want to be able to programattically change the values of those fields from time to time, and so wrote a function like so: ...
Jim Miller's user avatar
  • 1,948
2 votes
3 answers
1k views

How to add up all items of a field collection field using Rules?

I have a field collection with unlimited values. Inside this field collection, there is a field called Price (field_price). I would like to addup all prices that are inside the field collection to ...
No Sssweat's user avatar
  • 30.7k
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 ...
Yuseferi's user avatar
  • 21.6k
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 ...
radu c's user avatar
  • 4,350
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 ...
silkAdmin's user avatar
  • 2,814
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 ...
J-Fiz's user avatar
  • 1,363
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 ...
Bart's user avatar
  • 6,913
37 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 ...
LLub's user avatar
  • 3,652
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?
daphshez's user avatar
  • 1,082
31 votes
7 answers
27k 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 ...
David Barratt's user avatar
25 votes
5 answers
17k 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 ...
Sithu's user avatar
  • 4,933
23 votes
4 answers
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 ...
Nigel Waters's user avatar
  • 1,014
23 votes
2 answers
12k views

In what order are implementations of the of same hook done from different modules invoked?

Suppose there two modules, first_module and second_module which implement hook_user_login() hook. When a user logs in, which function is called first? How does Drupal decide the invocation order for ...
GiLL's user avatar
  • 1,733
21 votes
6 answers
15k views

How to find orphaned files and images which are not linked from any css stylesheet or from any node?

Is there a way to list all unused files which reside inside public file system and inside a theme directory and list them, or maybe even have an option to delete them automatically? I mean files ...
camcam's user avatar
  • 2,101

1
2
3 4 5
59