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

learn more… | top users | synonyms (1)

0
votes
0answers
11 views

Custom page callback gave 404 but the page content is correct

I have a page callback that shows users' related content and displays a custom login form if user is not logged in. The site worked in another server, but today I migrated it to this laptop, and the ...
1
vote
1answer
9 views

How to make commands invoked by drush_invoke not to fail after adding extra option?

I've added new option into drush command as suggested here: function hook_drush_help_alter(&$command) { if ($command['command'] == 'features-revert-all') { $command['options']['cleanup'] = ...
0
votes
1answer
8 views

How to add extra option to the existing drush command?

I'm trying to add extra option to the existing command as below: /** * Implements hook_drush_command_alter(). */ function MYMODULE_drush_command_alter(&$command) { if ($command['command'] == ...
1
vote
1answer
18 views

How to overridden command via hook_drush_command_alter?

I'd like to override command using hook_drush_command_alter before run as below: /** * Implementation of hook_drush_command_alter(). */ function policy_drush_command_alter(&$command) { if ...
0
votes
1answer
11 views

What hook can access every field label at once and change the label of one?

I am trying to change the display label of one field on a node (not the form), depending on the value set in another field in Drupal 7. I don't want to change the label in the database, just on the ...
0
votes
0answers
25 views

How to reindex a particular node in Drupal 8?

I want to index particular node on update, insert how to do it in Drupal 8? In drupal 7, we use the function function _node_index_node() I want to use the same function in drupal8 for my Drupal 8 ...
0
votes
1answer
17 views

What is significance of confirmation page before deleting a node?

I want to know what exactly usage of node confirm delete page except to avoid miss configuration.
0
votes
0answers
12 views

Hook before the file insert, before the file come on the server ?

I want alter the URI's files before they are stocked in the server. The file insert, I mean, everywhere/time a file is uploaded via Drupal (all insert file process, not only when an user add a file ...
0
votes
3answers
21 views

How to call functions from another module in hook_language_negotiation_info()?

I am writing a new custom module which is dependent on geoip module. I'm trying to add another language negotiation in the language detection configurations which would trigger a callback function ...
0
votes
1answer
20 views

Simple debug results in internal server error

All I want to do is print a view out so I can check the variables and see the structure of what's being created but it results in an internal server error. I'm using Acquia Dev Desktop. I've checked ...
0
votes
0answers
8 views

Modify the registration page in the membership entity module

I am new to drupal. I would like to remove some of the fields on the registration page of the Membership Entity module and add others. The new fields that I add need to be saved into the database. ...
0
votes
1answer
27 views

Alter field value before render

In Drupal 8, I was thinking that's a simple task but it's not : function hmytheme_preprocess_field(&$variables, $hook) { $element = $variables['element']; if ...
3
votes
1answer
28 views

Supressing “Undefined variable: variables in module_block_view()” without hiding the notice

I tried to create a simple custom block inside a custom module. there is a notice that inform me about undefined variable, but the block rendered properly. I am not sure where the mistake in the code ...
5
votes
3answers
45 views

How can I programatically prevent users from saving the same entity twice in a row?

My server sometimes gets overloaded, and sometimes people press the "Save" button on an entity creation page several times, which results in multiple versions of the same entity being created. So, I ...
0
votes
1answer
25 views

How to add js in view created by interface

I want to create a new button control in my ip_geoloc leaflet map. So, i created a view by using the drupal interface -> /admin/structure/views/view/markers_admin/edit And now i want to set a custom ...
1
vote
2answers
37 views

hook_load vs. hook_node_load?

Can someone explain clearly the difference between hook_load and hook_node_load? hook_load says it is a "node-type-specific hook". What does that mean? hook_node_load actually has a types parameter.
1
vote
1answer
12 views

How to alter command being run by drush_invoke?

When you run drush features-revert-all command, it can be altered using hook_drush_command_alter (&$command). However during run it's invoking another command by: drush_invoke('features-revert', ...
-1
votes
1answer
21 views

Convert hook_menu in drupal 8

I have a hook_menu as follows : /** * Implementation of hook_menu(). */ function conditional_fields_menu() { $items = array(); foreach (node_get_types() as $type) { $content_type = ...
-1
votes
0answers
21 views

I want to learn how to build drupal custom module [closed]

I have knowledge about CSS, HTML and little bit PHP. I am wondering how to get one-on-one support from a professional Drupal support provider. Would anybody refer me any good and affordable service. ...
1
vote
0answers
26 views

How to create private links to unmanaged files ?

I have created my own module with custom block to display private downloads to authenticated users. The downloads files are provided by 3rd-party system and stored in private folder of Drupal ...
0
votes
1answer
21 views

How do I send email to Users of a Role that belongs to Country using Rules?

I'm using Profile2 module to assign a Country to a Role. For example I have: User1 | Role: "International Members" | Country: "UK" User2 | Role: "International Members" | Country: "Poland" User3 | ...
0
votes
0answers
23 views

How to overwrite form submit? “Please enter some keywords” - Cant see my error

I have managed to get quite a few modules up and running and i'm now on my last sprint and got caught off guard by this small issue. I simply want to change: if ...
0
votes
0answers
18 views

how to create new drupal-wall node through custom module?

I have using drupal wall contributed module to posting purpose,and these posts create through custom module, i have used node_save() to create a new nodes. but problem is instead of user/author name ...
0
votes
0answers
12 views

Fatal error: Call to undefined function node_type_get_names() in C:\xampp\htdocs\kfd\modules\comment\comment.module on line 119

I am getting this error after installing one custom module i removed that module but still i am getting the same error message. Actully i defined same function accidentedly in two module. I install ...
0
votes
1answer
26 views

How to make view source code in single line

Is there any way to show rendered HTML in single line when you view source it in Drupal? You may see in some websites like facebook.com. So, when you view source the entire HTML will be in single ...
0
votes
1answer
16 views

How to override logic of specific drush command?

I'm aware of validate/pre/post COMMAND hooks and I would like to replace the logic of the existing drush command on specific condition using policy commandfile with something else, e.g. /** * ...
0
votes
1answer
8 views

Add more fieldset with remove option custom module

I'm developing custom module and there's one fieldset that can be added multiple times and can be removed any particular entry also. Can anyone please suggest to achieve this? Here is my code: ...
0
votes
0answers
39 views

Entity Field Query OR condition,between node title and a custom field

I am executing a query for searching in the node title and a field using LIKE.How do I use the OR condition? `function hook_somefunction($keys) { $query = new EntityFieldQuery(); ...
0
votes
1answer
24 views

How to write paragraph template to add tags and css classes?

I have a paragraph bundle (pr_bnd1), which has several fields as below: field_txt field_bg_clr (list field whose key values are mapped to a css class) field_font_clr (list field whose key values are ...
0
votes
1answer
14 views

How to add another html tag (i.e. span) before the field value renders using hook_preprocess()?

I have a field (field_txt) that renders properly, but now i want to add a tag around it so that i can style the background color of it. How would this be possible using the preprocess field hook? ...
0
votes
0answers
21 views

validation of a Content type field

I'm trying to validate a field of a content type. I've tried different approaches like with hook_form_FORMID_node_form_alter(), hook_field_validate() and even with the Field validate module. The ...
-2
votes
0answers
13 views

get slogan site for contents

i have created this module : display nodes with her : title , type, and site name, but i want that display site_name for each node Example : Node 1 : Type1, Site name 1 Node 2 : Type2, Site name ...
0
votes
0answers
8 views

How to add extra filed in commerce invoice table?

Hi I am using commerce kickstart module for e-commerce.I have also installed commerce_invoice and commerce_invoice_series modules.My question is I wont to add another extra field in commerce invoice ...
0
votes
2answers
25 views

Drupal File Validations When File Field Not Required

I have a (Drupal 7) custom form where the image or file field is not required, however when the form is submitted and the image or file field is NULL I get the below errors Notice: Undefined ...
0
votes
1answer
9 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 ...
1
vote
1answer
26 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
1answer
28 views

How to create suggestions conditionally (by block type/bundle) override system templates in Drupal 8

For example, I want to override image template (image.html.twig) to change how it outputs images from <img{{ attributes }} /> to <div class="image" style="background-image: url('{{ ...
0
votes
1answer
33 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 ...
4
votes
1answer
29 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
26 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
27 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
22 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 ...
-1
votes
1answer
28 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
3 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
37 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. ...