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

learn more… | top users | synonyms (1)

1
vote
2answers
49 views

How know inside hook_entity_presave() if it's a create or update?

How know inside hook_entity_presave() if the entity is create or update please ? Thanks. Note: I want use presave and not update and insert hook.
0
votes
1answer
23 views

Why do only some of my hooks get called?

I made a test module and only a few of my hooks seem to get called. I get the Javascript console messages for the block_view, form_alter and form_user_login_alter hook functions when I do the ...
0
votes
1answer
24 views

Add Attribute to Textfields in Admin Theme

I'm often working with Pages in RTL Languages where the default Theme and also the admin theme are using RTL languages. What often bothers me, is to use LTR texts like Tokens or Paths in Textfields, ...
0
votes
0answers
6 views

Drupal 7 Custom Module - Creating a Block with Visibility set to “Only the listed pages”

I have the following code. It does create the block but I still cannot figure out why it is not adding that block to the desired region and also pages visibility settings are not working. What am I ...
0
votes
1answer
10 views

Display POA in Ubercart 3 / D7 for products of zero dollars

I'm building an ecommerce site where some products are price negotiable and want a way to add POA instead of a listing a price when a product is displayed. I'm kinda surprised at how hard this is to ...
0
votes
0answers
14 views

Fatal error: Unsupported operand types in \core\lib\Drupal\Core\Routing\RouteBuilder.php on line 174

I'm working on hover_card module for its D7 to D8 upgrade. While working around I've got the following issue which is a blockage in the further development! Fatal error: Unsupported operand types ...
0
votes
1answer
12 views

How to print the raw value of a custom user field in comments

I want to print a custom user field of the commenters. It is an Link field (https://www.drupal.org/project/link). Some users have that field completed and other not. I've read a lot of posts related ...
0
votes
0answers
6 views

Adding class to nested UL in Drupal 7 menu

I'm creating my menu using view along with Bootstrap to create a mega menu style navigation. I'm having a problem with the nav showing expanded at times when you come to the site and or refresh. not ...
0
votes
1answer
32 views

Add field to existing content entity

I am trying to add a hidden field to all nodes in my module (for any node type even new ones being created later on). Would this be the correct code? $field_storage = ...
0
votes
1answer
13 views

Appending multiple tables in drupal 7 module

I am appending three new tables in my custom module using hook_update, but it is throwing below error when I try to run update.php file PDOException: SQLSTATE[22003]: Numeric value out of range: ...
3
votes
4answers
82 views
+50

How can I remove the “The image was resized to fit within the maximum allowed dimensions…” message without hacking core?

By default, Drupal prints out a notification message that images exceeding the maximum dimensions were resized. I want to disable this message. The relevant line is located in ...
-1
votes
0answers
10 views

How to play videos from different video providers like youtube, vimeo, dailymotion as a playlist in drupal 7?

Suppose I have 3 URLs of videos, First video url is of/from vimeo, second is from youtube and third is from dailymotion etc etc. How can I use these links as a playlist ? Like when first video from ...
0
votes
1answer
17 views

How do I use hook_views_pre_render in template.php in Drupal 7?

I have some auto generated data from my articles stored in a view(my_amazing_view). I also have a custom field in articles where user can enter similar data. If user has entered the data, i want to ...
1
vote
2answers
14 views

How might I have Webforms save files to private file system or as a database blob?

In Drupal 7, I have the file system configured as In the code for the Webforms' file component located at sites/all/modules/webform/components/file.inc, it appears that one could easily change it ...
0
votes
0answers
10 views

How to use other properties in hook_entity_property_info_alter()

I want to extend the entity properties of OG-Membership to use it as a token in rules. It works fine adding the property (for example the string 'test' as returned in the getter_callback is printed ...
0
votes
0answers
7 views

token does not work in upload directory of webform

i'm using service modules for generate json data , ve it's done in json data image data is inserted but i want to insert image url in json , how can i do this ? thanks for your helping
0
votes
1answer
12 views

Hook into Panels content form submit

I'm writing a routine to track inline image usage in panel panes every time the panels content form is submitted. The hook_panels_pane_update hook works, but only after the second time the form is ...
-3
votes
1answer
28 views

Decrypt automatic created drupal url [closed]

In my project url encryption and decryption are compolsary,so help me How to decrypt drupal automatically created url (eg: "q=content/testpage")?
0
votes
0answers
14 views

Is there any core or module functionality that automatically corrects URLs in node content bodies?

Background I'm investigating some odd behaviour on a Drupal 7 website. We're using the upload replace module to turn Drupal's file versioning on its head. However, there's a bug with this module ...
0
votes
1answer
8 views

links__system doesn't use URL aliases?

I'm trying to use the links__system preprocess function to output a menu as a select element, unfortunately though $link['href'] appears to output the URL in a format like: node/2 Even though the ...
0
votes
1answer
50 views

Implement Menu block hook function hook_menu_block_tree_alter() to add/change/remove classes

I have installed the plugin Menu block and I am very happy with the result, but I'd like to change some classes in the structure. This is what I get right now: <div class="content"> <ul ...
0
votes
0answers
5 views

display non published comments with special test and condition

How can i modify in the loop of displaying the comments in drupal 7 foreach (....) { if ($comment->stauts == 0 && $comment->condition ==1){ // Display comment with new class } } ...
-1
votes
0answers
9 views

How to add save as Draft button with custom callback in custom form [on hold]

I want a functionality in my custom form: How to add save as Draft button with submit button in custom form. Both Submit Button & Save As a Draft Button will be having different Callbacks. ...
1
vote
0answers
15 views

how to get form_state in Modal (ctools)

I Want to get the comment form_state in the ctools modal to change a variable i was trying to use drupal_get_form but i cannot access to form_state ? Before submitting the comment form i want to show ...
0
votes
0answers
10 views

How to insert multi image with restFul service on D7

i have a little issue i try to add to my node with RESTful service on drupal 7 multiple fid for a image gallery and i can't finish the process, i try 'field_gallery[und][0][]' => array( ...
0
votes
0answers
14 views

THEME_preprocess_field() not recognised in template.php

Mail (password reset, user blocked etc..) from admin sends messages without preserving linebreaks. Then I came across https://www.drupal.org/node/1095838 to fix this issue. In turn ...
0
votes
0answers
19 views

How to integrate remote Server Side Includes into theme?

I am trying to figure out how Drupal's theming system might accommodate a particular project of ours. We are considering using D7 for a client's micro-site. We will provide licensed content under ...
0
votes
1answer
24 views

using hook_user() to capture user actions

I am trying to create a method to log the actions of users, specifically when they log in and out. I am using hook_user() method to do this. This is my code. function mymodule_user($op, &$edit, ...
0
votes
1answer
27 views

New path creation through hook menu problem

I have installed Drupal 7. I created new module (.module file and .info file), enabled the module, and gave the permission to menu item also. If I go to localhost/siva/shop/catalog/products, it ...
0
votes
3answers
116 views

Drupal 8 custom page template

Is there any way to make custom page.html.twig template in Drupal 8? By default Drupal generates some suggestions but none if it is something like this page--node--content-type.html.twig..
0
votes
1answer
22 views

How to embed a view in hook_page_build()

I'm trying to render a view into a region in hook_page_build(). I'm using views_embed_view(), but I'm getting the errors: Warning: Invalid argument supplied for foreach() in element_children() ...
-1
votes
1answer
40 views

Is it possible to build a complete web site with Drupal 7 without using contributed modules or Hooks? [closed]

Is it a good programming practice to add your own hooks in a template.tpl.php or is it best practice to make all the changes possible into a custom module?
1
vote
1answer
34 views

How i can use entity_metadata_wrapper for new database entry and update data in Drupal 7

How i can use entity_metadata_wrapper for database entry and update data in Drupal 7 I am using below code to save entry in database but not finding logic to update existing entry $node = new ...
0
votes
0answers
22 views

Drupal Commerce: How to set Delivery charge depends on user billing address taxonomy term 'Area'?

I am using commerce_marketplace for handling multiple stores and i am trying to set delivery rate based on user billing address area taxonomy reference field on checkout. In my each store I need ...
0
votes
1answer
25 views

Running code only once when building a form

I have built a form using the field API. The function hook_field_widget_form gets called for every field. I have a bit of code that populates a select box but it is being called for every field in the ...
0
votes
1answer
26 views

How to add page argument in hook_menu for dynamic callback function?

I'm using groups for my website and I would like to create functions that will work for every group. I've created a tab configuration for every group like this. $groups = ...
0
votes
1answer
25 views

How can I redirect a user after adding a node that also added a new taxonomy term?

I have a content type with a Taxonomy for locations, these locations can be placed inside parent locations (f.ex United Kingdom -> England -> London), and it is set-up such that the end user can add ...
0
votes
2answers
50 views

How to create new field type

I'd like to create a new field type that can be attached to content (ie an article) via the admin interface through 'manage fields' of the content type. I am unsure of the process and required hooks ...
0
votes
1answer
18 views

menu callback path construction

It seems there is hardly any documentation on page call backs using URLS This being the case I have 2 questions: What is a legal callback path? and what becomes the URL to access that path? Here is ...
0
votes
0answers
8 views

Extending FeedAPI parser

Is there a way to extend the default parsers(or any) of the FeedAPI module? The parsers are implemented as separate modules (sub modules). So writing another parser is also a real headache (as ...
0
votes
0answers
26 views

node.tpl.php is not getting picked

I have a content type called news, I wanted to create a custom template for it because I had to embed a view just before the title. I created node--news.tpl.php and placed it in templates folder but ...
5
votes
2answers
157 views

Best way to delete all variables when uninstalling module

I'm writing a module that writes several variables (three, four variables for every content type, and other). Which method should I use to delete them on hook_uninstall? Is it safe to perform a ...
0
votes
0answers
28 views

change node types file fields widgets programatically?

I have installed multi_upload_filefield_widget. I would like to change every file widget of every file type fields of every node type programatically. i would need to automate this change since i ...
0
votes
3answers
53 views

Automating module activation during installation of Drupal

I want to add some modules in an installation profile, so that they are automatically installed during installation. Some modules need to be configured before using them. Is it possible to do it?
0
votes
1answer
14 views

Allow users to view others contents with autocomplete Entity Reference field

I'm trying to build a content type where any user can select an entity reference value through an autocompleted Entity Reference field. Using this field works as an admin. I'm able to see the ...
0
votes
0answers
12 views

cURL hangs the hook_user_update

I am using a cURL to notify remote site of some updates on my site. I use it with hook_user_update() which is used when user data is saved. Problem is that it takes a lot of time to do that (maybe ...
0
votes
2answers
36 views

How to add unique identifier to each submission?

In short, I am trying to figure out how to add a custom and unique identifier to each submission from the Webform module. Example: User fills out the Webform and submits. User then receives an email ...
0
votes
1answer
42 views

how to save a field created by using hooks in database

I added fields mobile no,landline no, using the below code to the form which i created with webform module. when i fill the fields along with two added fields and submit them .i cannot find the two ...
2
votes
1answer
81 views

Charts module settings per chart (with views integration)

(Drupal 7, Charts module, Views module) I'm creating charts with charts module + views. I want to set options for only some charts and found that in charts.api.php: /** * Alter an individual chart ...
0
votes
1answer
121 views

How would I clear values in ajax loaded select options?

http://pastebin.com/TX2UiJGZ I have 3 select drop-downs, selecting a value in the first populates the second using ajax, selecting the second populates the third. However when I change the value of ...