Hooks are PHP functions used to interact with the Drupal API.

learn more… | top users | synonyms (1)

0
votes
0answers
16 views

hook_node_presave() fired twice when adding new node

I've just noticed that hook_node_presave($node) is fired twice when adding new node. Once it's called from node_form_submit handler and the second time from entity_save. Turns out $node->nid is ...
0
votes
1answer
13 views

Template suggestion for 'content' in custom page

I need the equivalent for hook_preprocess_node for custom pages, which aren't nodes. The particular page I need to theme is provided by the entity registration module 'node/10/register'. I can add ...
0
votes
1answer
18 views

Drupal 7 method of hook_onload()

I want to add JS functions to the body tag's onload and onunload attributes with a custom module. The only hook I found was hook_onload() from Drupal 4.7, but this method has been deprecated. What is ...
0
votes
2answers
12 views

Add Help Text for User Roles Field on User Edit Page

I would like to add some help text for one of the fields displayed on the admin user edit page (the page seen when an admin edits a user account). The help text would provide a brief description of ...
0
votes
1answer
17 views

javasript invoking custom module to update user response

I have created Multiple choice questions in drupal . One node (page ) has one mcq . The answers are displayed by simple radio buttons and javascript . Now I am planing to give some dynamic behavior ...
0
votes
1answer
35 views

Moving functions in block module to inc file

I have searched everywhere for an answer to this question, and have found little to no help on the subject. The closest question to my own would be this, but the answer for it is a bit different than ...
0
votes
1answer
10 views

Theme webform using custom module

I know I could easily theme a webform using the webform-form.tpl template. However, I want to do this on the module level where the tpl is located inside the custom module folder or coded directly ...
1
vote
0answers
11 views

Add percentage based fee/tax to specific product types on checkout in Drupal Commerce

In Drupal 7 Commerce, I have two product types, a service product and a physical product. I would like a 6% fee added to all physical products only when the user gets to the cart review page. ...
0
votes
0answers
26 views

Creating a Module Level Main Menu Replacement

I am looking to create a module (not theme) that replaces/augments the main menu in Drupal 7. I've got a CSS driven menu (MegaMenu style). It's generic and I want to reuse it across ...
0
votes
0answers
30 views

Upload image temporary and on form submit make it permanent

I have made a custom module where I load the create node form for an "announcement" content type. What i want Besides the text and select fields, I require an image field which supports multiple ...
0
votes
1answer
27 views

Is there a “hook_user_login_failed” hook? Or something similar?

I'm needing to detect when a login failure happens in Drupal and am finding it to be exceedingly difficult even after searching Google. I have to believe this exists somewhere. I found this post ...
0
votes
1answer
25 views

hook never called

File C:\wamp\www\sites\all\modules\custom_user\custom_user.info: name = Custom User description = Custom User core = 7.x dependencies[] = alter_ego File ...
0
votes
0answers
22 views

How to change sort of view 3 results based on exposed filter value?

I am showing user profiles trought views. There is one exposed filter (term reference field in user profile). For two fixed values (All and 1330) i need to change order of results from field_fullname ...
0
votes
1answer
25 views

Download count of file in table of files

So I wanted to add date alongside the size of the file in filefield table of files so I added this snippet to templates.php function mytheme_file_formatter_table($variables) { $header = ...
0
votes
1answer
20 views

hook_url_outbound_alter only for links in node body

I'm building a site with drafts/revisions as a major component. For now I'm using hook_url_outbound_alter to check if "/draft" is at the end of the current URL, and if so to append "/draft" to all ...
0
votes
2answers
22 views

How to compare new node title with already entered nodes in database

I am using node gallery module.While creating an album, when the user enters duplicate name then error message is displayed as This form requires that the fields Album name, Author are a unique ...
0
votes
0answers
10 views

Can't get hook_field_attach_view_alter to set the value of the field

I'm using some hook code I got from Drupal 7 show empty fields in order to show all of the empty fields on my node when viewing it. I would like to put a simple - as the displayed value when the field ...
1
vote
0answers
16 views

Determine whether a field has changed during hook_node_submit

Basically I need a way of checking whether a node field changed during some event hook...I am using hook_node_submit() but this doesn't seem to work: $form['field_status']['und']['#value'] !== ...
0
votes
1answer
52 views

Bootstrap Theme: Theme hook suggestion for user profiles

I've tried to create theme hook suggestions in my template.php to use template files in combination with view modes. My code snippet: function blogtheme_preprocess_user_profile(&$vars) { if ...
0
votes
1answer
16 views

Append an <i> tag to entity field view hook

On a field of field type = LINK and widget = LINK, I want to add an tag on the rendered output. The reason is to be able to add a class, not to the whole tag output, but to append a FontAwesome ...
0
votes
1answer
63 views

Code for viewing comment reply form (drupal 7)

I would like to add_css when comment reply form is viewed (not new comment form) and there is an example code below. How could the line $comment->nid == $node->nid (presumed to be responsible for ...
0
votes
0answers
21 views

hook_views_default_views_alter with handler

Is it possible to add new column with a new handler for hook_views_default_views_alter? I have previously implemented hooks_views_data_alter to add a new column and a new handler. In this ...
0
votes
0answers
24 views

drupal_add_js doesn't 'stick' outside of hook_js_alter and hook_page_alter

Putting together a module that needs to insert javascript into each based on the contents of the page being viewed. The following code block works fine in hook_js_alter and hook_age_alter: ...
0
votes
0answers
12 views

Data updated in views->result does not get rendered

During the hook_post_execute process I'm trying to update some node fields. The idea is to make some calculations using data from views->result and then update the nodes. The node fields I want to ...
0
votes
1answer
71 views

How to parse current page URL query parameters to create link using l() function

I have a view in D7 with a few exposed filters. This view generates a URL/page like this: example.com/node?location=XXX&check-in=XXX&check-out=XXX&lang=XXX. I am looking to build a link ...
1
vote
2answers
69 views

Problems adding javascript to a specific page

Drupal Version: 6.x Currently, I have a custom module created. In my template, I keep html code that I would like to embed within a container, such as a div, with a particular id. For this question, ...
1
vote
0answers
50 views

How to use user_load() for user on $_GET[] request in Drupal way?

I'm trying to get UID of users on $_GET[] request, following is my module code: my_module.module function hover_card_init() { $module_path = drupal_get_path('module', 'hover_card'); ...
0
votes
0answers
19 views

Extend admin/content by one taxonomy filter and avoid views

I'm looking for a possibility to add a taxonomy as a fliter criteria on the admin/content page. The following link https://www.drupal.org/node/1162340 describes something but hacks core. As I ...
0
votes
1answer
40 views

Drupal hide form items completely with states

I try to hide a whole date/image/taxonomy block on my node form dependent on a checkbox. If use the following for my title field it works perfectly. The title field is hidden/visible dependant on the ...
1
vote
1answer
16 views

How to add IE specific stylesheet in drupal 7 in drupal way [duplicate]

I want to add this into my Drupal site in a Drupal way! <!--[if IE]> <link type="text/css" rel="stylesheet" href="IE.css" media="all" /> <![endif]--> I know it can be done easily ...
1
vote
2answers
34 views

Printing current node workflow state name as the page body classes

I have a workflow system in my site using workflow module, and I need to print the node current state name as body class. I did the same with user current role in template.php with this snippet: ...
1
vote
0answers
31 views

How to Change View Filter Operator in Views Filter

I want to Set View Filter Operator to "Less Than Or Equal To" <= in Views Filter of Drupal 7. MACHINE NAME field_guests FIELD TYPE List (integer) WIDGET Select list
1
vote
1answer
32 views

What hook is most appropriate for code that should run as early as possible in bootstrapping but only on certain paths?

I am writing a module that should run code as early as possible because it's a conditional redirect to another page, so the first page doesn't need to finish loading. I only want to run it on /foo/*. ...
0
votes
0answers
11 views

customize ubercart payment gateway error message USAePay

We're currently using D6 and Ubercart with the USAePay gateway. Unfortunately, the USAePay gateway does not handle international postal codes very well. But when it returns an error the HTML is ...
1
vote
1answer
25 views

unsetting field via view hooks no effect on aggregation results

I have created a view, with some aggregation parameters. I expected that unsetting (removing) the aggregation field via some view hook (views_pre_render?) would do the trick to disable the ...
0
votes
1answer
36 views

How do I add to $page_top in html.tpl.php?

I wanted to add a piece of HTML at the top of all pages, right after <body>. In the #drupal IRC channel I got the recommendation to override html.tpl.php in the theme. That works fine. But isn't ...
1
vote
3answers
84 views

How to intetrupt a form submission in drupal

I have made a custom module where I create one page. In that page I load the existing form for creating a new content and also add a password field. In my loaded form I have an email field. I want ...
1
vote
1answer
30 views

How to use hook_menu to add an item to the secondary links?

Adding an item to the primary links is easy: function hook_menu() { $items = array(); $items['bla'] = array( 'title' => 'bla', 'page callback' => 'mymod_blah', ...
0
votes
1answer
37 views

Registering User Programatically with only Email Address

My Drupal 7 site utilizes the email_registration and logintobbagan modules. It works fine to register users with just their e-mail address. However, on a separate page I am using a newsletter ...
0
votes
2answers
82 views

how to output image file from database drupal 7?

I have created testing module that will upload image and outputting it to my page. but, I can't seem to output my image file from my database. here's my code function database_ex_menu() { $items = ...
0
votes
0answers
13 views

Passing a variable set to value of og_group_ref field causes functions to return empty

I have the following hook: /* Implementation of hook_comment_insert() */ function my_utils_comment_insert($comment){ if($comment->node_type == 'comment_node_post'){ $author = ...
1
vote
1answer
28 views

how to write hook that hides /shows fields if option selected in node creation

I'm needing help writing a hook that will remove price display and show a text field if a "hide price" option is selected during node creation. It just needs to be hidden in the node and catalog ...
-1
votes
1answer
17 views

Can I work with hook_user_login() directly within user.api.php?

Somewhat new to Drupal... this is probably a softball for all you Drupal pros out there. I need to update a custom table in the database each time a user logs into Drupal. I thought I'd be able to ...
0
votes
0answers
22 views

Appending a submit handler to user_pass_submit to enable form redirect after submission

If I understand correctly, having $form['actions']['submit']['#submit'][] = 'my_extra_submit'; in a hook_form_FORM_ID_alter would execute my_extra_submit after it executes the default handler. ...
0
votes
1answer
61 views

Drupal 7 views 3 add custom filter handler for an existing field

How can you implement custom filter handler for an existing field in Views 3? With hook_views_data() you can expose a new table to views but how can you alter the handler for an existing field?
0
votes
1answer
23 views

How to make blocks contextually aware of current webform page

I have a multipage Webform that lives at a single URL and I would like to place certain blocks depending on which page the Webform is on. None of the webform hooks give access to page number, and the ...
0
votes
1answer
28 views

Theme function cannot be found Drupal

For some reason my theme function is not being found by Drupal. I swear I have followed everything and spent hours of time trying to make this work to no avail. Plus with not a single answer in the ...
0
votes
1answer
171 views

Saving and Publishing nodes to different domains based on revision

Need some creative help (or obvious answer/new module I'm missing). Still rusty in Drupal, so bear with me here... Using: Domain Access, Revisioning, and custom module using hook_node_presave() ...
1
vote
1answer
44 views

Is there a hook when a relation is created, updated or deleted?

I know how to use hooks like hook_node_presave. Is there also a hook to catch the deletion of a relation or the update of a relation? In the API I cannot find anything. Maybe there is a workaround? ...
1
vote
1answer
45 views

Do something in hook_node_load only when displaying node

Is there a way to run a specific block of instructions in hook_node_load only when the node is loaded do be displayed and not when it's loaded in the edit form? The only way I can imagine is ...