Questions tagged [hooks]

Use it for the mechanism that allows to extends module's functionality without editing its code.

Filter by
Sorted by
Tagged with
-3
votes
0answers
18 views

Calling Microsoft Azure Queue from Drupal custom module is not working [on hold]

Use case is to invoke MS Azure queue code as and when the external file loads into Drupal physical storage of file path to update as message. The standalone PHP interface is working as expected with ...
0
votes
0answers
18 views

Enabled Text Compression

We would like to enable text compression for our sight. We tried to look, but could not find any contrib modules that do this. We are already using advagg to compress the JS/CSS files. It does not ...
1
vote
0answers
14 views

How to render translated node body in two languages?

I use entity_translation to translate node body field, so in a fully loaded node object body is an array of 2 languages ('en' and 'ru'). For specific node type I would like to render body in both ...
0
votes
1answer
34 views

Add Button to Node View

I want to add custom button on node page. I tried with hook_node_view but it didn't show up. like this: function mymodule_node_view(array &$build, EntityInterface $entity, ...
-1
votes
0answers
8 views

Send webform to selected Entity in 'wizard page' based webform

I have a content type Member with field Email. This member is used as field in webform, where anyone can select a specific member using Entity autocomplete field when filling webform. How can I force ...
0
votes
1answer
47 views

Should we document AJAX-callback parameters?

Considering the PHPCS warning: phpcs: Hook implementations should not duplicate @param documentation Is there any way to tell PHPCS that the function is an AJAX-callback (so that such warnings are ...
1
vote
0answers
40 views

How to preload generated styles and scripts?

I'm trying to preload my main css and js files - these files are generated using the AdvAgg module. I've tried using the hook_preprocess_html in a theme and in a module, but in the $variables['page'][...
0
votes
1answer
38 views

Add separate div after a form

All I want to do is add a new <div>, ideally just after a <form> element. I have a self-written module that generates a payment form, using some routing, like this: mymodule.applications....
0
votes
1answer
10 views

How to add library if Ajax is enabled for view?

We have a view, myview, where Ajax is disabled. We created a custom library that would override the load more button's indicator so that we can use our own. However, we would only like to add this ...
-2
votes
0answers
21 views

I have created an entity with a Bundle. Now i figured out there is no need for the bundle. How to remove bundle of my entity?

what are all the changes that i have to make to my drupal module to make sure that it is not of bundle. I deleted entitytypeinterface and all but still i am unable to add content to my entity. Is it ...
-3
votes
0answers
36 views

How to show/hide div based on the radio button selection in form alter?

I have a content type, having a field with radio buttons. Radio button describes a list of the interest. Field Name: field_interest Field Type: Select List (checkbox-radio enabled in the form display ...
0
votes
1answer
29 views

One field (entity reference - paragraph) with two display modes

I am having issue with displaying one field twice in my template having different display modes. I have a content type basic page with field field_gallery (which is entity reference on paragraph). In ...
0
votes
0answers
17 views

Show who published a revision/page - publish history [duplicate]

I would like to know which user published a page or revision of the page and when was it published. Is there something like publish history? In the image we can see only the revision (date and author ...
0
votes
1answer
28 views

Field contains list and values of it are shown in one symbol

I'm developing a drupal module and there's a problem. I need to make a content type with some fields and one of them should have list with string values. But when I try to create content and choose ...
0
votes
2answers
32 views

How to implement a text field formatter that renders a URL as the image?

If a node has a text field with the url of an image as its value, how can I render this field as the image? The image does exists it will be given the image url. I have to write that url into the ...
0
votes
0answers
9 views

Add a button on the login form

Is it possible to add a button on the basic login form? function alter_form_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if ($form_id == 'user_login_form'...
0
votes
0answers
32 views

Alter a Field Collection display order inside a FieldCollectionHook

I have been stuck in here since yesterday and I'm starting to run out of ideas. I have a Field Collection that contains 2 fields. The first one is a multiple taxonomy term, and the second one is a ...
0
votes
0answers
34 views

How to get identifier for menu link item in form hook?

How to get something unique (like 'menu link id' mlid in Drupal 7) in the form for editing one menu link item? hook_form_alter(&$form, FormStateInterface &$form_state, $form_id) { $mlid=... ...
0
votes
1answer
13 views

Hooking into page specific instance of checkout flow form

I'm working on manipulating the buttons used for the checkout flow of using D8 Commerce 2. I'm using MYMODULE_form_commerce_checkout_flow_multistep_default_alter but its changing both the form buttons ...
0
votes
1answer
66 views

Before login hook

Is there a Drupal 8 hook for pre-login? I would like to redirect the login information of a user on a web server by URL. I know there is hook_user_login(), but this one only looks called once the ...
0
votes
1answer
36 views

Get field machine name inside HOOK_preprocess_file_link()?

I am hoping to get the field name inside the HOOK_preprocess_file_link. Only wanting to alter the link of the file for certain field names. Hook_preprocess_field() would probably work, but would ...
0
votes
0answers
14 views

Alter Entity Reference data before view is rendered

I am attempting to work around a bug where an Entity Reference Field on User Account is saving duplicate references. I originally tried to remove any duplicates on the field by implementing ...
1
vote
1answer
95 views

Modified user record during presave hook not saving properly

A project I am working on has a bug where an array field on the user object is getting duplicated values. To fix this bug, I am implementing the hook_user_presave hook in one of our custom modules to ...
-1
votes
1answer
14 views

Watchdog in `hook_user_presave` implementation causing unknown error [closed]

In my own module, my_user.module, I am trying to implement the hook_user_presave invoked from user.module. Following the examples, I created a function in my module like so: /** * Implements ...
0
votes
0answers
15 views

Custom facet processor not displaying on facet setting

We have a custom module,mymodule, where we create a custom facet processor for a facet we created (myfacet). When we enable the module and cleared the cache we are not seeing the new processor display....
0
votes
2answers
28 views

How do you use hook_form_FORM_ID_alter() to alter the USER EDIT form?

I'm trying to mark fields on the /user/_uid_/edit screen as disabled. These are custom fields I've created in /admin/config/people/accounts/fields in D8. I have this code for another node entity type....
0
votes
0answers
6 views

Produce array of results from view that has a pager

I am trying to get an array of all the view results in a views_hook_pre_render function. The problem I am running into is that the view has a pager (and needs a pager because it has thousands of ...
1
vote
1answer
43 views

Field collection item code not working

Hi Every one I am trying to create new field collection item programmatically but code is not working. I want to create a number of field collection items but no Luck. My code is following. use ...
1
vote
2answers
66 views

Fetch view results from mymodule_preprocess_page hook

We have a View page that is coming from myview. Using the header setting in the view we have added @total results already, which displays in the views-view--myview--page-1.html.twig using the {{ ...
0
votes
1answer
24 views

Accessing the uri within the template_preprocess_image_formatter

I am using template_preprocess_image_formatter and I am trying to access the uri protected property inside the URL array (see screenshot) does anybody know how to access it?
0
votes
1answer
47 views

How owerride entity node delete core function

I'm doing a headless drupal cms. I need to check the entities before they are deleted. I need to do it globally as the deletion of entities can take place via api (already written) or by using the ...
0
votes
2answers
45 views

How to get all values from a new node being created in hook_ENTITY_TYPE_presave()

Drupal 8.7.2 function mymodule_node_presave(Drupal\Core\Entity\EntityInterface $entity) { data_dump($entity->original); //is empty because its a new node, not a node being updated. // How to ...
0
votes
1answer
62 views

Get Current Applied Image Style Name

How do you get the currently chosen image style name from the field format display option? I can load an image with a given style with the code below, however, the style name (e.g. thumbnail) is hard-...
0
votes
0answers
17 views

How to print contact email in the receipt email?

I've got a question regarding receipt emails. I saw the doc about customization of receipt emails espacially the available theme_hooks. I'll need to get the contact info (email) in the receipt email....
0
votes
0answers
18 views

Zoom API error - Only available for enabled v2 webhooks

I have installed ZoomApi module and also created app in marketplace with JWT. When I am going to webhook page, Its giving error:- ZoomAPI\Exception\ApiException: [400] Error handling response. [...
1
vote
1answer
46 views

Possible to theme the form's elements with own twig?

I was thinking to get twig outputs so I could use these twig variables on a form.html.twig such as below: <div class="row"> <div class="col-md-6"> {{ form.name }} ...
0
votes
2answers
72 views

AJAX callback inside hook_form_alter()

I don't know how to implement AJAX callback in hook_form_alter(). The field is plain text by default and it is populated by NID (number) of the client company. The module name is "my_car". I didn't ...
0
votes
1answer
174 views

Strip html tags in preprocess hook

We have a mytheme.theme file that has a mytheme_preprocess_node(&$variables) function. Within this preprocess hook, we would like to remove all HTML tags within a formatted (long) field. The goal ...
0
votes
1answer
49 views

Hook for Node Add Field?

For my use case, this question revolves around the entities node and paragraph. Fields in my projects are created under the following structure: content_h2 paragraph_h2 content_p paragraph_p ... ...
0
votes
0answers
13 views

How to show external PHP in custom module view?

I have created a custom module which contains the hook_block_view and inside that I'm calling a function which only has this code ( the data.php only contains html and php to print a table ): ...
0
votes
0answers
14 views

Automatically add meta tags on node creation

I'm currently maintaining a lot of different sites containing the same information pages (example: profile pages with the same content but on different sites/base URL) and I'd like to consolidate this ...
1
vote
1answer
47 views

How to use hook_prepare to modify a field of a node before it is edited

I want to modify the contents of a field of an Article node just before it comes up for editing. I have read the documentation at http://api.hostdog.gr/api/drupal-8/drupal%21core%21modules%21node%...
-1
votes
2answers
33 views

CIDRAM on Drupal 7 [closed]

Has anyone installed CIDRAM (access management to block undesirable IP addresses) on Drupal 7. It requires adding a "php require" statement to a file that is executed on every attempt to access the ...
0
votes
2answers
45 views

Get value of programmatically (form_alter) added fields at form submit

I'm altering a node creation form using the form_alter hook in a custom module. In this particular case, I'm adding an email field which is not part of the content type structure. At the node creation,...
1
vote
1answer
22 views

Set value on a new term based on a vocabulary custom field

I want to set the value of a field of a term based on a custom field set on the vocabulary. Basically if the vocabulary promote_to_index field is checked I want to the field_index_page of the term ...
1
vote
2answers
33 views

How do I change the Views (Entity Reference) filter via AJAX?

I have an entity form that allows an admin to select a content type (checkbox) and an autocomplete field that is tapped into a VIEWS Entity Reference (via the Reference Method). Goal: What I would ...
0
votes
1answer
199 views

Get node based target id from entity reference

We have an Article content type which has an Entity Reference field called field_document that is linked to the Media bundle type of Document. In mymodule we need to write a hook that will take the ...
0
votes
0answers
12 views

Is it possible to use hook_views_query_alter to compare the value of two fields?

We have a D8 site with a view that links a Content-->Paragraph-->Content. We also have language translation enabled so the views_ui module displays duplicate rows for all combinations for the content ...
0
votes
0answers
26 views

View presents fewer items per page after using Unset

I'm deleting items by means of an unset in hook_views_post_execute, as far as the view I have it configured by 10 items per page. The problem is that it shows me sometimes 6 or 8, I have searched for ...
0
votes
0answers
36 views

Hooks vs Events vs Extension - when to use what?

Im writing a module. One thing it will do is alter the menu edit form. I've been looking at core code and examples on the internet and can't really figure out when to extend Drupals core classes, use ...