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

learn more… | top users | synonyms (1)

0
votes
1answer
4 views

How to process field input so b52 goes into database as B-52

Situation: D7 Text field on a content type. User enters something like: b52 I want it stored in the database as: B-52 I have a function that does the regex. I just don't know where to process the ...
0
votes
1answer
6 views

Un-promote all other nodes when one node is promoted to front page

I have an instance for a specific content type that at any given time there can only be ONE item promoted to the front page. I have a view that looks for this value and displays the item in a block on ...
0
votes
0answers
13 views

How to override image.html.twig only in specific block type in Drupal 8

I required that image template is <div class="image" style="background-image: url('{{ attributes.src }}');"></div> But only in specific block type b_partner_images. I will have at ...
0
votes
1answer
15 views

Is hook_file_download the right hook for taking action when a private file is downloaded?

I'm trying to create a module that will fire send an event via google analytics' Measurement Protocol API when a file is downloaded. These files are all in the private file system outside of the ...
0
votes
0answers
32 views

Create custom widget block [on hold]

Can anyone suggest on best and easiest approach to create custom widget block for Yes/No survey with 10 questions shown consequently in drupal sidebar block after each yes/no button clicked. And at ...
0
votes
0answers
7 views

When a node is being created I want to hit this API service with the email I have [on hold]

When a node is being created (hook_node_presave) I want to hit this (https://www.fullcontact.com/developer/ )API service with the email or phone I have........plz help me to create it
4
votes
1answer
25 views

How to delete field programmitically using hook_update?

We have a situation where in different environments we have to manually delete fields. Rather than manually doing that, we want to programmatically deploy the changes. The idea that is being is ...
0
votes
1answer
24 views

Achievement Popup notification doesnt appear on cache page

I am using achievement module on site , it shows a popup notification when a particular achievement is reached . However due to caching (Authcache for authenticated user) , the popup doesn't appear . ...
0
votes
0answers
14 views

Custom view theming with Lightbox 2

I've a view that shows file type (video, audio, image and document) in a bootstrap grid. Now i want to add a pupop effect on each element of the view using lightbox2 module. But i don't really know ...
0
votes
1answer
24 views

How to change cardinality(delta) of nodes in Drupal 7?

I have a Content type, This content type has a Field collection with cardinality(delta) value 1. I want to alter it dynamically, when the node add form is rendered. Each node add form has it ...
1
vote
1answer
22 views

How to add a “company name” as a user value for permissions and a data variable

I am creating a site that allows multiple different company's access to separate resources. Access to resources is dependent on the user's role and the company they are registered to. Sample User ...
0
votes
1answer
20 views

What hook do I use to add a field to a content type after it was programmatically created?

I have a module that created a custom content type with some fields. Now I need to update the content type with a new field and wanted to know what hook do I use? As of now my content type was ...
0
votes
1answer
12 views

Move menu code to the template.php with the associate hook

I have created a region (called menuCustom) .info file in my template, I created a custom menu and I'm showing in the previously created region. I created a file called block--menuCustom.tpl.php to ...
0
votes
0answers
13 views

Drupal 7: Understanding the API [closed]

I am going through bits-n-pieces of code on a website my friend gave me to understand the PHP code and the Drupal API, so in the future I can hook in my own custom modules. But I am quite confused. ...
0
votes
1answer
20 views

Is there any preprocess hook for date api?

As I asked in above, Is there any theme preprocess hook for date api in drupal? I want to Perform Some mathematical operations on Dates That show on any type of Contents, Is there a any way to a to ...
0
votes
0answers
2 views

How to change from name in inbox private message?

By default in inbox for private message showing username as from address. i want to change it to firstname and lastname instead of username. ex: ***/messages from | Subject | Date ...
0
votes
0answers
10 views

Hook to alter field content before being manually rendered

I have a template which doesn't call render($page['content']); but instead displays content with calls to field_get_items/field_view_value. I would like to use a hook to alter this field (body) ...
0
votes
1answer
33 views

how to use “hook_services_request_postprocess_alter” to wrap field with CDATA in drupal 7?

May i know how to use "hook_services_request_postprocess_alter" .I have field called 'body' in $result ,I want to wrap it with CDATA.Any idea how to do it? &$result[0]->body is my variable. ...
0
votes
1answer
23 views

I need to use hooks without using theme and module

I'm in a project that needs to add features to Drupal Core without using themes niether modules. I have implemented a class that makes different things, but I need to use hooks or something similar. ...
1
vote
1answer
37 views

How to set different themes for multiple domains in Drupal 8

I am developing a multidomain site with same code base and single data base. I am trying to set themes for multi domains which was previously supported by domains theme module in drupal 7. Don't ...
3
votes
1answer
26 views

How do I filter entity reference fields based on language?

In a Drupal 8 site I have a node content type "page" that references a custom entity type using inline entity form. "Page" also has a paragraphs field usig the Paragraphs module. The site have ...
0
votes
0answers
8 views

How to alter a form for the translation of an entity?

Both hook_form_alter and hook_form_FORM_ID_alter in my module are getting triggered before the entityFormAlter in the ContentTranslationHandler. So the 'Delete Translation', which replaces delete is ...
1
vote
0answers
32 views

Pre save hook to save a field value as node title

I have a custom date field in a node type 'day'. When the node is saved (or edited then saved), I would like to get the field_date value (not the published date) and save it into the title field. I ...
0
votes
0answers
10 views

Access pane settings from a view

Is there a way to access pane settings from the view pre build hook? I have a view being rendered inside a content pane. I have altered the pane's settings form and added a setting field. Now I need ...
3
votes
3answers
36 views

How to extend a module hook from another module?

I want to be able to clone/replicate a node from one language to another on click of a button using a custom module. Basically we have a view which displays all nodes in the system and under the ...
0
votes
2answers
36 views

Where can I alter the path of the anchor around a views items title?

I have a view with several items and they link to their respective nodes. However I also have an external URL field which if populated needs to replace the path around the title of the views item. ...
0
votes
0answers
22 views

How to hook “uc_cart_complete_sale” without broking this ubercart function

I try to understand the hook system of ubercart but there this something i don't get it at all. My main objective it to add a js code to the page "cart/checkout/complete" to send to an external ...
0
votes
0answers
42 views

Hook into node/entity creation/insert

Functionally, what I want to achieve is to duplicate a node (with a different node-type) when creating/inserting. To be more precise: I have two content types: news and press-release. What I want to ...
0
votes
1answer
50 views

Using the same hook more than one times [closed]

I have several custom modules and each one of them serves different functionalities. Each module contains from few to many hook implementations and inevitably there are cases where I have to use a ...
1
vote
1answer
19 views

Advance Search form $form is not the same when invoked a second time?

I Want the users to have an expanded advance search form if no results are returned from a search. The advance search form on the search page always defaults to collapsed. I found that I can check ...
1
vote
1answer
28 views

Newbie-question: how to use hooks [duplicate]

Ok, this is a newbie-question i'm afraid to ask for some time .. how to use Drupal Hooks? Yes, i know where to look for the code, but then? Put it in the template-folder, a block, a custom module? ...
0
votes
0answers
19 views

How to add LEFT JOIN to views query which is newly generated on table sorting

I have created a views with table format like below screenshot: When a user clicks on City head (in red circle) the Clinic/Hospital (C/H) column is misorderd and I also noticed field for C/H is ...
1
vote
0answers
15 views

Modifying search terms in Drupal 7 Search API

My end goal is to wrap each keyword in * essentially enabling wildcard searches (partial word search). For instance, if I type "word" into the search box I get 99 results, if I type "wor" into the ...
0
votes
3answers
31 views

Hide Block on Particular Page with Bootstrap

I have a block called 'calendar' that I display on all events pages. events* such as events/today/, events/all/ etc. A constraint that I have is that the block must be displayed on all events pages ...
0
votes
0answers
23 views

views_embed_view is overriding the output in hook_services_views_execute_view_alter

I'm working with Drupal 7.x with services 3.x and views 3.x module, below is the code which I've in my custom module. When I'm executing the same, views_embed_view() overrides the output of the whole ...
0
votes
2answers
37 views

Filtering list of nodes with attached views by taxonomy of node

I have a single article (page) which has an attached view thats displays a load of nodes (in a content called 'courses'). These nodes have a term reference field called 'language' which assigns them ...
1
vote
1answer
39 views

How to alter sort handler to keep existing order intact in views

I created a views page using foo plugin.When a user visit the page the city and Clinic/Hospital columns by default are being rendered alphabetically (ASC) as in below screenshot. EDIT: Let's say for ...
0
votes
0answers
6 views

Prevent (all languages) being displayed in multilingual entity forms?

So i have entities setup with translations enabled some fields are "all languages" i.e. their not set to be translated. I don't want to have "(all languages)" on my form labels. How do i prevent or ...
0
votes
1answer
52 views

how to access custom function in twig template file

I've write small custom function in my .theme file. Is it possible to call that function in twig template files? I would like to fetch description value for a field in views template file, so can we ...
0
votes
0answers
19 views

How to modify the entire block search and the result?

I'm trying to enable the block search with advanced search in a single block ( Adding an extra button on this set ) . But I have not been able to achieve , I think I should use the ...
0
votes
1answer
18 views

Run hook update N in different batches

I am trying to update drupal. I want to break the updates into 2 different runs/groups. I want run the second batch of updates after the first is done. The first batch contains the updates from the ...
0
votes
1answer
22 views

hook_node_update hitting a wall with a loop I created

I have a taxonomy multi-select list that is used to create/delete entries in a field collection in my node. I'm trying to make it so that if the user deselects an item from the taxonomy list, the ...
1
vote
1answer
42 views

How can I set the help text as an input placeholder on the user login form?

On the user login form, I am trying to take the "help text" and make it an input placeholder (so that the help text shows up in the input and disappears when the user enters their username and ...
0
votes
2answers
17 views

Help link doesn't appear in module page

What do I have to do to show help link in module menu? My code looks like: /** * Implements hook_help(). */ function mymodule_help($path, $arg) { if ($path == 'admin/help#mymodule') { ...
0
votes
2answers
34 views

Why does my code for checking field permissions allow users to register with the same email address?

Based on the Examples module, I tried to set up permissions on some user account fields so that only admins can read them. However, the code below somehow allows users to register with the same email ...
1
vote
1answer
28 views

Protected $view values inside template_views_pre_render function?

I'm trying to alter the view page title by using the template_views_pre_render function inside mytemplate.theme file. It works fine, I'm able to modify its title this way: ...
1
vote
1answer
16 views

Hook within an exisiting hook?

I have one hook, "hook_form_commerce_checkout_form_alter" and that is modifying something on my checkout process. Within that though I have a switch statement that if true I want to use ...
1
vote
1answer
41 views

Add multichoice question to quiz node programmatically

I'm using the latest version of drupal and quiz module. In my custom module, I have created a quiz by using below code $quiz = new stdClass(); $quiz->title = 'Testing Quiz'; $quiz->type = ...
0
votes
0answers
16 views

Replacing Views Query and Displaying Results

I'm relatively new to Drupal and I am working on a view that needs to show both Users and Nodes in the same table. The solution that I have come up with is to use hook_views_pre_execute to replace the ...
0
votes
2answers
35 views

hook_node_access called more than once

I have this very simple implementation of hook_node_access function applx_node_access($node,$op,$account){ drupal_set_message($node); } This returns applx_application forum article page forum ...