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

learn more… | top users | synonyms (1)

0
votes
0answers
4 views

How do we add a button to the node/edit page that on click translate current node to selective languages?

We are looking for a way to add a button on the node/edit screen to allow someone the ability when the button is clicked to basically clone the page into a different select set of languages? For ...
0
votes
1answer
20 views

How to create variable to start last cron run from custom module?

We have a custom module for which we need to run on a daily basis. I am not sure it is working, as I am unable to store the time correctly. Does the following code allow me to create a variable, ...
0
votes
0answers
10 views

How to setup cron to call my custommodule function every day? [duplicate]

I am creating a custom module and i am attempting to setup a cron job to have a custom function run my module, but need some guidance as i cannot get to run properly. Below is a sample of what we are ...
0
votes
0answers
17 views

Hook menu alter fail to load menu items? but permission check succeed

I tried menu_alter hook and its working great with permission access denied or access granted, but I realise all the menu items associated with the wildcards are not showing when clicking on the menu ...
0
votes
2answers
19 views

Create content after editing other content-type

I have a certain content-type B with an entity reference to items of content-type A. I'm trying to programmatically create a content-type B node when a bool field in content-type A is set to true, ...
1
vote
2answers
100 views

How to use hook_form_search_block_form_alter?

I was referring this page in the process of learning hooks How to Customize the Block Search Form and found following code. /** * hook_form_FORM_ID_alter */ function ...
0
votes
1answer
34 views

How can we achieve multiple forms in a single page?

I have menu callback which is getting called multiple times on the same page by an AJAX request resulting rendering the form with same HTML id $items['mymodule/page'] = array( 'page callback' =&...
0
votes
0answers
33 views

How use highchart with filter?

I'm new to Drupal and I'm following this tutorial, I have a filter that checks a status of valid or notReadyValid. This filter can be taxonomies. But to my chart I have data like this: if( $...
0
votes
1answer
36 views

Add location to to profile2 just after the user registers

I am trying to force add a location to a user's profile2 just after the user register's an account. The user's are able to add locations to their profile by using flags, but since there are no ...
0
votes
1answer
18 views

Accessing values entered in custom fields added to install_configure_form

In my installation profile, I have added a text field to the install_configure_form by including: if (!function_exists("system_form_install_configure_form_alter")) { function ...
0
votes
2answers
20 views

Notice Undefined variables [on hold]

I have many notices in my site. Notice: Undefined variable: item in include() (line 79 of templates/page.tpl.php). Notice: Trying to get property of non-object in include() (line 79 of templates/...
1
vote
2answers
29 views

Send mail to the admin when user fails to login

I need to implement the functionality to notify the admin user via email whenever someone fails to login entering wrong password. Basically simple email format containing the username for failed ...
0
votes
1answer
29 views

Help with hook_views_pre_build() [duplicate]

I have set up a View to show a list of stories, and then set up an attachment to my View that puts the first 4 stories at the top of the View styled differently. I need those 4 to only show on the ...
1
vote
1answer
32 views

How to only define hook_menu path to certain URL [duplicate]

Consider this simple implementation of hook_menu() /** * Implements hook_menu(). */ function helloworld_menu() { $items['hello'] = array( 'title' => 'Hello world!', 'page callback' =&...
-3
votes
1answer
53 views

Creation of a Content Type to Meet Required Use Case

How do I achieve the following Use Case? Use Case Example Widgets, Inc. offers franchising opportunities. They have 3 different franchising levels (bronze, silver and gold). Widgets, Inc. needs to ...
1
vote
1answer
21 views

How to remove id=“node-[nid]” with Display Suite?

How I can remove the node id when I override a node layout with Display Suite? In some (old) how-to I noticed that the id node is not present when a node layout is overridden with DS. i.e.: from ...
1
vote
1answer
23 views

Trouble sending redirect after logout

I'm trying to send a redirect after logout, but it is not sending properly. I tried using the hook_user_logout in a module as follows: use Drupal\Core\Routing\TrustedRedirectResponse; function ...
0
votes
0answers
30 views

Get current language in block

There is a twig file named link--language-block.html.twig and I'd like to get current language in there. In front page (page--front.html.twig) it can be done using {{ language.name }} . But, it ...
1
vote
1answer
53 views

Why the template_preprocess_field hook is not called for a custom template?

I'm working in a site that have implemented the template_preprocess_field() hook. I want to change the content of a field but the code works for all the nodes except for the nodes of a content type ...
2
votes
2answers
26 views

what's the difference between using js injector module and ['#attached']['js']

Please can any one tell me what's the difference between: adding a java script to a webform using js injector module And adding it using Implements hook_form_alter() and $form['#attached']['js']
0
votes
0answers
15 views

The front page is being queried when I request a menu item, and I can't figure out why

I'm setting up a website at the minute where I've set up some reusable code that generates mosaics of content, the general idea is that content is pulled through on page load and more is loaded with ...
5
votes
3answers
52 views

How do I execute code before update the content?

How do I execute code before updating nodes? I am looking for a hook to use in a custom module. I have created a content type. What I need to do is execute a hook before updating any content. I want ...
0
votes
0answers
17 views

changeable form according to the Selected options

I have a little problem: I have a content type called "PRODUCT" Administrator add an infinite numbers of "PRODUCT" and each "PRODUCT" had a name and a description and a form (like the webform) the ...
0
votes
1answer
27 views

Changing '#view_mode' in content type's render array

I have a content type in Drupal 8 project that has image, name, info and body field as a default display, and image,name and information as a teaser display. I am able to display this content type ...
2
votes
2answers
54 views

List the hooks that can be used in .install file?

I have found only few hooks that can be used in the .install file. They are: hook_enable hook_disable hook_install hook_uninstall hook_requirements hook_update_N hook_schema hook_schema_alter ...
1
vote
1answer
20 views

Drupal 8: How can i get the node id the comment is attached to in hook_comment_insert?

How can i get the node id the comment is attached to in hook_comment_insert? I tried the following code. function mymodule_comment_insert(Drupal\Core\Entity\EntityInterface $entity) { if ($entity-&...
0
votes
1answer
17 views

Can't update hook_theme after clearing the cache

I have a hook_theme instance in my template.php which outputs various components in my theme. I want to add an extra argument to one of the templates but no matter what I do it doesn't update. I have ...
0
votes
0answers
10 views

Not possible to override js/misc/ajax.js using hook_js_alter in Bootstrap theme

I am trying to specify another custom ajax.js file in place of js/misc/ajax.js using hook_js_alter(&$variables) but with no success. Upon inspection of the &$variables array, my target file js/...
1
vote
2answers
29 views

Check content type of node in preprocess hook

I have a series of variables I want to make available on twig templates for specific content templates. In mytheme.theme I have function mytheme_preprocess_node(&$variables){ if(isset($...
1
vote
1answer
39 views

Hook_menu() doesn't work [closed]

Here's my code and I can't get why hook_menu doesn't work. My block menu doesn't showing in menu. As I understood this code (hook_menu()) should show link in which for will work drupal_post_form ...
1
vote
0answers
22 views

Permissions on non Drupal generated content

Relative newcomer to Drupal 7 and I'm still coming to terms with some of the naming conventions used, so please forgive me if I bork the language up front. The problem I am trying to solve: I'm ...
1
vote
1answer
99 views

programmatically disable menu based on user taxonomy reference fields

I am trying to programmatically disable menu based on account settings/user taxonomy term field, is there a better way to do it? do I need to use hook menu? to disable already built menu, as I have a ...
1
vote
0answers
19 views

How to modify menu-block template with preprocessor in theming level

I am trying to modify menu block that locates in primary region with preprocessor in theme level but I don't think I will be able to accomplish without a lead or advice. So this image is what I need ...
0
votes
1answer
17 views

call a modules function from preprocess_page

I want to be able to call the current nodes taxonomy tree from page.tpl.php by using a function already in the taxonomy module. So far I've only been able to obtain the current nodes taxonomy id with: ...
0
votes
1answer
22 views

Programically update node when visited by 'editor' role

My goal is to have promote-node-when-visited-by-editor feature. This is code from MYMODULE using hook_node_view: function MYMODULE_node_view($node, $view_mode, $langcode) { // 'promote-node-when-...
0
votes
0answers
13 views

Increase weight range of menu items

Is there any hook or trick that allows to increase the weight range of menus? By default Drupal 7 has from -50 to 50. I have more that 100 menu items and i noticed that sometimes this can cause ...
1
vote
0answers
12 views

How to get commerce product variation presave in drupal 7?

I need insert data when product variations of node is updated , i tried hook_entity_update() and others but they didn't help to reach my aim.
-1
votes
1answer
32 views

How do I get the login form submitted values in hook_user_login()?

Since hook_user_login() in Drupal 8 has only 1 arg, how can I get the values submitted in the form? In other words, what is the equivalent of $edit['input]['element_name'] I would use in Drupal 7?
0
votes
0answers
20 views

How to allow anonymous user to complete checkout after some time based on order ID

I am working on an ecommerce store which is based Drupal Commerce. On site, I have allowed anonymous checkouts which work fine. However, for some products with unsual dimensions( for shipping ...
1
vote
0answers
12 views

Webform Form Submit Handlers - Dynamic

With Formbuilder, I was able to add custom submit handlers using the form id. This custom handlers get added only if it is admin site. What I am not able to be sure of is, could these custom submit ...
0
votes
1answer
24 views

hook_entity_view_alter - redirect

First up I'm very new to the Drupal way of things but have jumped on board with Drupal 8 and quite excited about the possibilities. What I'm trying to do is redirect the default node view route (i.e. ...
1
vote
1answer
39 views

How do I replace a string when using hook_node_view()?

I am trying to use hook_node_view() to replace, in the front page, <div>:placeholder1:</div> with the content of $string. function mymodule_node_view(&$node, $view_mode, $langcode){ ...
1
vote
0answers
13 views

hook_apachesolr_exclude not working

I am using hook_apachesolr_exclude but its not working.I have created a custom field if that field is checked i want to exclude that node I wrote the given below code: function ...
1
vote
3answers
73 views

How can I theme the Bootstrap base theme search block?

I've created a sub-theme of the Drupal 8 Bootstrap base theme. My problem is that I'm using a customized version of the Bootstrap CSS Framework that does not include Glyphicons. Instead of Glyphicons, ...
0
votes
1answer
61 views

Remove vertical tabs?

I bought a module on Envato. I've already contacted the developer, but he does not respond. The module outputs some vertical tabs. They are created with this code. /** * Implements of ...
0
votes
0answers
15 views

How to get the parameters in hook_menu function correct? [duplicate]

I'm developing my first custom module and I need some help with it. When a user is clicking on the following <a download=”filename.docx” href="exporttoword/567?xml=/xmlcv&template=/internal....
0
votes
1answer
23 views

How to check order exist or not in commerce order?

I am using Drupal 7.31 and the Commerce Kickstart distribution. I added an order using CSV file in commerce_payment_transaction table. I want to check the condition below: if (isset($_POST['submit'])...
1
vote
1answer
21 views

Active menu trail for multiple menu item with the same path

It is possible to have menu items that point to the same node and have the active state dynamic? If I click the link 'List item A1' I would like to become active the link 'List item A'. If I click ...
0
votes
0answers
18 views

Updating Term Reference Field via Hook Update

This question is about Drupal 7. I'm adding a new vocabulary, MY_VOCABULARY, and some default terms to a feature using the UUID Features module. For deployment purposes, I enable the feature via ...
1
vote
1answer
23 views

How can i set a variable based on this render element $vars[‘body’][‘#object’][‘vid’];

In trying to learn about theming and Drupal’s alter functions I’m looking at the render array(?) of the hook_node_view_alter function like this: function hook_node_view_alter(&$build) { dpm($...