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

learn more… | top users | synonyms (1)

0
votes
0answers
10 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 ...
0
votes
0answers
9 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
14 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. ...
0
votes
0answers
13 views

How to embed image in MIME mail

I used MIME Mail module to send my email. Right now, I would like to embed some images in my email. In my module, I used following code: $body1[]='<img src="https://upload.wikimedia.org/wikipedia/...
0
votes
1answer
34 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){ ...
0
votes
0answers
19 views

I want to upgrade my module but cannot find any suitable documentation [on hold]

I see that there are tons of changes in Drupal 8. Yet, there is no comprehensive documentation about the drastic changes. It's getting really painful to upgrade the module to Drupal 8. Any help or ...
0
votes
0answers
9 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
2answers
34 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
57 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
14 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
22 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
17 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
16 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 ...
0
votes
1answer
19 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($...
1
vote
0answers
34 views

How do I create shortcodes for displaying nodes according to tags?

I want to create a shortcode, which is a specific code that lets you do nifty things with very little effort. Shortcodes can embed files or create objects that would normally require lots of ...
1
vote
0answers
12 views

How to add span tag in to webform element label? [duplicate]

I am trying to style my webform checkboxes and radio buttons differently. For this reason I want to insert span element in to the label and use it instead of original checkboxes. Found this module : ...
1
vote
0answers
17 views

How to add watchdog logging to organic groups

I have a Drupal 7 site which makes use of the organic groups module. I would like to add helpful watchdog log messages when users are removed from a group. What are some options? ...
0
votes
1answer
23 views

How do I programmatically change the query “limit”?

I've created listing with views module in which page has 9 items and only in first page the sixth item should be advertisement instead of result item. It means all items after sixth element should be ...
0
votes
0answers
19 views

Creating CSV in Post Save Hook

I'm trying to create a CSV from data taken from nodes within a website. So, I've created a custom module to handle this - making use of the Form API to create an admin page. Once the CSV is generated, ...
1
vote
1answer
17 views

Checking caller of a hook

Is it possible to know which code called a hook? I have two cases--one where I want to return, one where I want to continue. Anonymous user views a page, thus firing hook_entity_load() (I want to ...
0
votes
2answers
28 views

In Drupal 8 can a developer inject Full HTML Pages?

I have done a lot of work in WordPress but want to develop a new site in Drupal 8. I have two specific questions before I start on my site. Is it possible to inject full HTML pages via PHP into a ...
0
votes
1answer
36 views

What is an alternative to hook_node_view()?

When a node is rendered in a panel pane, hook_node_view() is not invoked. (I use Panels 7.x-3.4.) Is there any alternative to change rendered node content in any other hook? I have tried with ...
1
vote
2answers
31 views

Redirect after comment submit according to value of query string in comment form URL?

For redirecting user to some page after comment submit my below code is working fine : function my_module_form_alter(&$form, $form_state, $form_id) { if ($form_id == "comment_node_link_form") ...
1
vote
2answers
42 views

How to change new theme for a content type

Requirements: Create content type based theme. I have a requirement to create content based theme, I mean if the content type is article then node view call theme-1 and if type is basic page then ...
0
votes
0answers
17 views

What is the hook to alter user object for encrypt and decrypt

I want to encrypt some of the user data while storing into DB. Similar way, want to display original value(decrypted) where ever it needed. Using encrypt module to encrypt some of user object data(Ex:...
1
vote
0answers
11 views

Edit Authorization form using theme callback and theme template

I'm trying to remove sections of an authorization form that is in a contrib module oauth2 sever module, but it's not working and I get the following warning : Warning: Illegal offset type in isset or ...
1
vote
1answer
54 views

Redirect (or show the node) taxonomy term page to node, if there's only one node associated with that term

So I'd like to redirect taxonomy term page or show the full content of the node on taxonomy page if there's only one node associated with that term.
0
votes
1answer
33 views

Rendering field with the help of functions

I have a field and I can render its value in a such way: <?php print $entity1->field_list_of_options['und'][0]['safe_value'];?> But I have many different entities at the page so I want to ...
1
vote
1answer
17 views

Can`t alter views filter option

I need to alter my view filter option! The view must display some comments. Every comment, that I need, has custom field "node reference". And I want to filter comments by this field. E.g. if my ...
1
vote
0answers
13 views

How do i change the time between 2 reservation in Agreservations?

i didn't spoted any field that can change that. I book meetings rooms that can be booked multiple time in a day (hour reservation). But for exemple i have one reservation early morning (8:00 to 9:00),...
0
votes
0answers
4 views

Deleting/altering Referenced Etities Via Module

I am writing a module and would like some input on whether my approach sounds good from a drupal standpoint. There is a content type that I've created where each node has a number of referenced ...
0
votes
1answer
29 views

Able to use custom variables in page.html.twig but not in menu.html.twig

I have a module setting config variables which I'm trying to display in a twig template. When I use function mytheme_preprocess_page(&$variables){ $variables['facebook'] = \Drupal::config('...
3
votes
1answer
32 views

Override base url when creating links to public files

I need storage the upload into drupal file in another server and I need change public path to files to example http://server_with_image/image How I can do this?
0
votes
2answers
27 views

How to delete all data in one field of a particular content type?

We have a content type basic page that has a Date field (field_bp_date). We want to use the hook_update to delete all data in this field. We are having trouble figuring out what is the best way to ...
0
votes
1answer
23 views

views information in exposed form hook

I am trying to compare views in exposed form but so far there is no way I am getting views information in exposed form. Is there any way to do so? I need to compare view id for theme suggestion.
3
votes
2answers
24 views

Customize menu local task links

I am looking for a way to customize 'edit', 'view', 'delete' links. I use bootstrap theme, but i use bootstrap v4 styles for it. I want to add 'nav-link' class to each link. And find a way to ...
1
vote
1answer
55 views

How to change uploaded file name after save node?

Hello and thanks for looking my question. On Drupal 7 I use this hook hook_file_presave() for change file name. function mymodule_file_presave($file) { $parts = pathinfo($file->filename); $...
1
vote
1answer
39 views

How to make select option works like a button?

I have created a contact form by using webform module, in that I have added one component as reset and the type is select options. My requirement is when I choose this reset option from that dropdown ...
1
vote
0answers
15 views

How can i add new action for selected users

I would like to add a new action within the With selection field and i don't know how to alter that data, i have tried with hooks but i can't find something that's working. If you ever done something ...
3
votes
2answers
53 views

Hide authoring information programmatically in a content type

How do I programmatically hide the Authored by part in a content type using hooks?
0
votes
2answers
23 views

Put a Form in the Site's Homepage

I have the item menu in my hook_menu. //Calls a function that enables creating, updating and deleting ID Templates. $items['user/%user/myid_templates'] = array( 'title' => 'MyID Templates', ...
1
vote
1answer
26 views

How can I overwrite a hook from a theme

I have a custom sub-theme of the Seven theme. The Seven theme makes some node alteration via seven_form_node_form_alter(). I would like to have seven_form_node_form_alter() not run at all or I would ...
1
vote
1answer
26 views

Is it possible to detect access to table on site db table and redirect the db query to a db shared by multiple websites?

I'm working on a project where I use a database that is common to all sites and another that is specific to each. Is there a way to detect access to a specific table on a contrib module (maybe using a ...
1
vote
1answer
20 views

Display Node edit under edit tab

I would like to know whether the "node edit form" (admin form) can be displayed under the edit tab itself using MENU_LOCAL_TASK?
1
vote
1answer
20 views

if term reference is value X in tpl.php file

I want it so that in my page.tpl.php file if the user has selected "Standard" as the "Page Type" term reference it prints an extra bit of html. I tried something along the lines of the code below but ...
1
vote
1answer
57 views

Drupal 8: How to implement hook_views_query_alter

I try to implement hook_views_query_alter in Drupal 8. I found a hint, that it has to be in my_module.views_execution.inc. I tried it, but the hook never gets called. function ...
2
votes
1answer
35 views

How to render a contact form as rendered entity

I have a question about rendering a contact form as a rendered entity. I have a field in my contenttype where form should be displayed. The field has the type Contact form. In the Manage display ...
3
votes
2answers
66 views

How to compare the already saved value of node and updated value?

I want to programmatically compare a field value of a node in hook_node_update(). How can I get the already saved and the updated values?
0
votes
0answers
21 views

If view results are odd, append the result with another row

I have 3 Views. Each have 1-9 items. The problem is that if the user adds an odd number items, I want to be able to add another. So my logic is to count the rows, if it the row count is odd, insert ...
1
vote
2answers
32 views

How to add element not appearing on the page via node_view_alter?

Given the following code: function mymodule_node_view_alter(&$build) { $node = $build['#node']; if ($node->type != 'podcasts') { return; } $build['new_section'] = array( '#...