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

learn more… | top users | synonyms (1)

0
votes
1answer
9 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 ...
0
votes
0answers
6 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
23 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
27 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
26 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
24 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
21 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
22 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
19 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
7 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
15 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
38 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
15 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
60 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
17 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
21 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
58 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
60 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
48 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
16 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
38 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
15 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
25 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
25 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
10 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
22 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
27 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
81 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
29 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
35 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
72 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
10 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
27 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
16 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
34 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
22 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
43 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 ...
1
vote
1answer
56 views

How can I remove emoji from all user input?

It looks like iPhone emoji are not currently supported in Drupal 7 on MySQL. When I try to save a node containing an emoji (I 💛 U!) in the database, I get an SQL error: PDOException: ...
0
votes
2answers
31 views

How to debug hook_form_BASE_FORM_ID_alter not working?

I am at wits' end. I have a clean install of Drupal 7.28 and a custom module with the following two hooks: /** * Implements hook_form_alter(). * / function mymodule_form_alter(&$form, ...
0
votes
2answers
44 views

hook_pathauto_alias_alter() on bulk update

EDIT: I've found out that this question doesn't make sense. The problem isn't that the hook is not called during the bulk_update. The problem is that the code generates unexpected aliases because of ...
0
votes
0answers
25 views

download count module increment 2 times [duplicate]

i am using file download count module and set file field as a file force genric. but, when user download any file, now its increment 2 times i have done debug and find the issue.. so i found in ...
0
votes
2answers
45 views

How do I add HTML to my module's custom admin page?

I have set up a new page in my admin for my module like so: /** * Implements hook_menu(). */ function scraper_menu() { $items = array(); $items['admin/scraper'] = array( 'title' ...
1
vote
2answers
57 views

Which hook to use to reorder multi-value field values before saving content

I have a multi-value field added to my content type. It is actually a field collection. The users can add unlimited items to this field, and rearrange the items using Drupal's drag-and-drop utility. ...