id
stringlengths
22
22
drupal_version
stringclasses
1 value
source_type
stringclasses
1 value
source_url
stringlengths
70
167
instruction
stringlengths
87
500
context
stringlengths
16
10.7k
response
stringlengths
68
5.97k
tags
listlengths
2
2
created_at
timestamp[s]date
2026-09-30 00:00:00
2026-09-30 00:00:00
api-drupal7-a8e669a9c8
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_view/7.x
Give me the example code for `hook_view($node, $view_mode, $langcode = NULL)` in Drupal 7. Hook description: Display a node.
This is a node-type-specific hook, which is invoked only for the node type being affected. See Parameters: - $node: The node to be displayed, as returned by node_load(). - $view_mode: View mode, e.g. 'full', 'teaser', ... - $langcode: (optional) A language code to use for rendering. Defaults to the global content lang...
function hook_view($node, $view_mode, $langcode = NULL) { if ($view_mode == 'full' && node_is_page($node)) { $breadcrumb = array(); $breadcrumb[] = l(t('Home'), NULL); $breadcrumb[] = l(t('Example'), 'example'); $breadcrumb[] = l($node->field1, 'example/' . $node->field1); drupal_set_breadcrumb($b...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-a90f3882dd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.report.inc/function/theme_update_version/7.x
I need the code for `theme_update_version($variables)` in Drupal 7 (modules/update/update.report.inc). It must do this: Returns HTML for the version display of a project.
Parameters: - $variables (array): An associative array containing: - version: An array of data about the latest released version, containing: - version: The version number. - release_link: The URL for the release notes. - date: The date of the release. - download_link: The URL for the downloadable file. - tag: The titl...
function theme_update_version($variables) { $version = $variables['version']; $tag = $variables['tag']; $class = implode(' ', $variables['class']); $output = ''; $output .= '<table class="version ' . $class . '">'; $output .= '<tr>'; $output .= '<td class="version-title">' . $tag . "</td>\n"; $output ....
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9107ceac9
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21module.inc/function/module_load_include/7.x
I need the code for `module_load_include($type, $module, $name = NULL)` in Drupal 7 (includes/module.inc). It must do this: Loads a module include file.
Examples: Parameters: - $type: The include file's type (file extension). - $module: The module to which the include file belongs. - $name: (optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default. Returns: The name of the included file, if...
function module_load_include($type, $module, $name = NULL) { static $files = array(); if (!isset($name)) { $name = $module; } $key = $type . ':' . $module . ':' . $name; if (isset($files[$key])) { return $files[$key]; } if (function_exists('drupal_get_path')) { $file = DRUPAL_ROOT . '/' . d...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a925196f96
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21update.inc/function/update_build_dependency_graph/7.x
I need the code for `update_build_dependency_graph($update_functions)` in Drupal 7 (includes/update.inc). It must do this: Constructs a graph which encodes the dependencies between module updates.
This function returns an associative array which contains a "directed graph" representation of the dependencies between a provided list of update functions, as well as any outside update functions that they directly depend on but that were not in the provided list. The vertices of the graph represent the update functio...
function update_build_dependency_graph($update_functions) { // Initialize an array that will define a directed graph representing the // dependencies between update functions. $graph = array(); // Go through each update function and build an initial list of dependencies. foreach ($update_functions as $module...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9419a0135
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_filters/7.x
I need the code for `node_filters()` in Drupal 7 (modules/node/node.admin.inc). It must do this: List node administration filters that can be applied.
Returns: An associative array of filters. File: modules/node/node.admin.inc
function node_filters() { // Regular filters $filters['status'] = array( 'title' => t('status'), 'options' => array( '[any]' => t('any'), 'status-1' => t('published'), 'status-0' => t('not published'), 'promote-1' => t('promoted'), 'promote-0' => t('not promoted'), 'stick...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a950bee86a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21tracker%21tracker.module/function/tracker_node_delete/7.x
In Drupal 7, write the function `tracker_node_delete($node, $arg = 0)` (file modules/tracker/tracker.module) so that it does the following: Implements hook_node_delete().
Deletes tracking information for a node. File: modules/tracker/tracker.module
function tracker_node_delete($node, $arg = 0) { db_delete('tracker_node') ->condition('nid', $node->nid) ->execute(); db_delete('tracker_user') ->condition('nid', $node->nid) ->execute(); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-a95c981b2a
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_file/7.x
Implement `theme_file($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a file upload form element.
For assistance with handling the uploaded file correctly, see the API provided by file.inc. Parameters: - $variables: An associative array containing: - element: An associative array containing the properties of the element. Properties used: #title, #name, #size, #description, #required, #attributes. File: includes/f...
function theme_file($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'file'; element_set_attributes($element, array('id', 'name', 'size')); _form_set_class($element, array('form-file')); return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a96ebe065e
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_set_active_trail/7.x
Implement `menu_set_active_trail($new_trail = NULL)` in PHP for Drupal 7. Required behavior: Sets the active trail (path to the menu tree root) of the current page.
Any trail set by this function will only be used for functionality that calls menu_get_active_trail(). Drupal core only uses trails set here for breadcrumbs and the page title and not for menu trees or page content. Additionally, breadcrumbs set by drupal_set_breadcrumb() will override any trail set here. To affect th...
function menu_set_active_trail($new_trail = NULL) { $trail = &drupal_static(__FUNCTION__); if (isset($new_trail)) { $trail = $new_trail; } elseif (!isset($trail)) { $trail = array(); $trail[] = array( 'title' => t('Home'), 'href' => '<front>', 'link_path' => '', 'localized_o...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a97a39518f
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/format_xml_elements/7.x
I need the code for `format_xml_elements($array)` in Drupal 7 (includes/common.inc). It must do this: Formats XML elements.
Parameters: - $array: An array where each item represents an element and is either a: - (key => value) pair (<key>value</key>) - Associative array with fields: - 'key': element name - 'value': element contents - 'attributes': associative array of element attributes - 'encoded': TRUE if 'value' is already encoded In bot...
function format_xml_elements($array) { $output = ''; foreach ($array as $key => $value) { if (is_numeric($key)) { if ($value['key']) { $output .= ' <' . $value['key']; if (isset($value['attributes']) && is_array($value['attributes'])) { $output .= drupal_attributes($value['attrib...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a97fa69794
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_vocabulary_confirm_delete/7.x
Implement `taxonomy_vocabulary_confirm_delete($form, &$form_state, $vid)` in PHP for Drupal 7. Required behavior: Form builder for the vocabulary delete confirmation form.
File: modules/taxonomy/taxonomy.admin.inc
function taxonomy_vocabulary_confirm_delete($form, &$form_state, $vid) { $vocabulary = taxonomy_vocabulary_load($vid); // Always provide entity id in the same form key as in the entity edit form. $form['vid'] = array('#type' => 'value', '#value' => $vid); $form['#vocabulary'] = $vocabulary; $form['#id'] = '...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9bb6d911d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_file_system_settings/7.x
In Drupal 7, write the function `system_file_system_settings()` (file modules/system/system.admin.inc) so that it does the following: Form builder; Configure the site file handling.
File: modules/system/system.admin.inc
function system_file_system_settings() { $form['file_public_path'] = array( '#type' => 'textfield', '#title' => t('Public file system path'), '#default_value' => variable_get('file_public_path', conf_path() . '/files'), '#maxlength' => 255, '#description' => t('A local file system path where publi...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9bebb1e43
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21path%21path.module/function/path_taxonomy_term_delete/7.x
I need the code for `path_taxonomy_term_delete($term)` in Drupal 7 (modules/path/path.module). It must do this: Implements hook_taxonomy_term_delete().
File: modules/path/path.module
function path_taxonomy_term_delete($term) { // Delete all aliases associated with this term. path_delete(array('source' => 'taxonomy/term/' . $term->tid)); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-a9cd3718e4
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_stream_wrapper_get_class/7.x
In Drupal 7, write the function `file_stream_wrapper_get_class($scheme)` (file includes/file.inc) so that it does the following: Returns the stream wrapper class name for a given scheme.
Parameters: - $scheme: Stream scheme. Returns: Return string if a scheme has a registered handler, or FALSE. File: includes/file.inc
function file_stream_wrapper_get_class($scheme) { $wrappers = file_get_stream_wrappers(); return empty($wrappers[$scheme]) ? FALSE : $wrappers[$scheme]['class']; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9d3d2d0b0
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/_install_configure_form/7.x
Implement `_install_configure_form($form, &$form_state, &$install_state)` in PHP for Drupal 7. Required behavior: Form constructor for a site configuration form.
Parameters: - $install_state: An array of information about the current installation state. File: includes/install.core.inc
function _install_configure_form($form, &$form_state, &$install_state) { include_once DRUPAL_ROOT . '/includes/locale.inc'; $form['site_information'] = array( '#type' => 'fieldset', '#title' => st('Site information'), '#collapsible' => FALSE, ); $form['site_information']['site_name'] = array( '...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9d6680f7f
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_weight/7.x
I need the code for `form_process_weight($element)` in Drupal 7 (includes/form.inc). It must do this: Expands a weight element into a select element.
File: includes/form.inc
function form_process_weight($element) { $element['#is_weight'] = TRUE; // If the number of options is small enough, use a select field. $max_elements = variable_get('drupal_weight_select_max', DRUPAL_WEIGHT_SELECT_MAX); if ($element['#delta'] <= $max_elements) { $element['#type'] = 'select'; $weights ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9e60bbef5
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/_field_invoke_default/7.x
In Drupal 7, write the function `_field_invoke_default($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array())` (file modules/field/field.attach.inc) so that it does the following: Invoke field.module's version of a field hook.
This function invokes the field_default_[op]() function. Use _field_invoke() to invoke the field type implementation, hook_field_[op](). File: modules/field/field.attach.inc
function _field_invoke_default($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array()) { $options['default'] = TRUE; return _field_invoke($op, $entity_type, $entity, $a, $b, $options); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9f64f6509
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_managed_file_process/7.x
I need the code for `file_managed_file_process($element, &$form_state, $form)` in Drupal 7 (modules/file/file.module). It must do this: Process function to expand the managed_file element type.
Expands the file type to include Upload and Remove buttons, as well as support for a default value. File: modules/file/file.module
function file_managed_file_process($element, &$form_state, $form) { $fid = isset($element['#value']['fid']) ? $element['#value']['fid'] : 0; // Set some default element properties. $element['#progress_indicator'] = empty($element['#progress_indicator']) ? 'none' : $element['#progress_indicator']; $element['#fi...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-a9f8b5032e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_menu/7.x
In Drupal 7, write the function `image_menu()` (file modules/image/image.module) so that it does the following: Implements hook_menu().
File: modules/image/image.module
function image_menu() { $items = array(); // Generate image derivatives of publicly available files. // If clean URLs are disabled, image derivatives will always be served // through the menu system. // If clean URLs are enabled and the image derivative already exists, // PHP will be bypassed. $directory...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-aa048c9525
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_link_parents_set/7.x
I need the code for `_menu_link_parents_set(&$item, $parent)` in Drupal 7 (includes/menu.inc). It must do this: Sets the p1 through p9 values for a menu link being saved.
File: includes/menu.inc
function _menu_link_parents_set(&$item, $parent) { $i = 1; while ($i < $item['depth']) { $p = 'p' . $i++; $item[$p] = $parent[$p]; } $p = 'p' . $i++; // The parent (p1 - p9) corresponding to the depth always equals the mlid. $item[$p] = $item['mlid']; while ($i <= MENU_MAX_DEPTH) { $p = 'p' . ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aa118c9290
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_actions_manage/7.x
In Drupal 7, write the function `system_actions_manage()` (file modules/system/system.admin.inc) so that it does the following: Menu callback; Displays an overview of available and configured actions.
File: modules/system/system.admin.inc
function system_actions_manage() { actions_synchronize(); $actions = actions_list(); $actions_map = actions_actions_map($actions); $options = array(); $unconfigurable = array(); foreach ($actions_map as $key => $array) { if ($array['configurable']) { $options[$key] = $array['label'] . '...'; ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aa2c70d682
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_sort_css_js/7.x
In Drupal 7, write the function `drupal_sort_css_js($a, $b)` (file includes/common.inc) so that it does the following: Sorts CSS and JavaScript resources.
Callback for uasort() within: - drupal_get_css() - drupal_get_js() This sort order helps optimize front-end performance while providing modules and themes with the necessary control for ordering the CSS and JavaScript appearing on a page. Parameters: - $a: First item for comparison. The compared items should be assoc...
function drupal_sort_css_js($a, $b) { // First order by group, so that, for example, all items in the CSS_SYSTEM // group appear before items in the CSS_DEFAULT group, which appear before // all items in the CSS_THEME group. Modules may create additional groups by // defining their own constants. if ($a['grou...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aa43bbc5ab
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21book%21book.install/function/_book_install_type_create/7.x
In Drupal 7, write the function `_book_install_type_create()` (file modules/book/book.install) so that it does the following: Creates the book content type.
File: modules/book/book.install
function _book_install_type_create() { // Create an additional node type. $book_node_type = array( 'type' => 'book', 'name' => t('Book page'), 'base' => 'node_content', 'description' => t('<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.'), 'custom' => 1, ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aa73ef8143
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/_filter_xss_split/7.x
In Drupal 7, write the function `_filter_xss_split($m, $store = FALSE)` (file includes/common.inc) so that it does the following: Processes an HTML tag.
Parameters: - $m: An array with various meaning depending on the value of $store. If $store is TRUE then the array contains the allowed tags. If $store is FALSE then the array has one element, the HTML tag to process. - $store: Whether to store $m. Returns: If the element isn't allowed, an empty string. Otherwise, the...
function _filter_xss_split($m, $store = FALSE) { static $allowed_html; if ($store) { $allowed_html = array_flip($m); return; } $string = $m[1]; if (substr($string, 0, 1) != '<') { // We matched a lone ">" character. return '&gt;'; } elseif (strlen($string) == 1) { // We matched a lo...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aa89a6c29c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21php%21php.module/function/php_eval/7.x
Implement `php_eval($code)` in PHP for Drupal 7. Required behavior: Evaluates a string of PHP code.
This is a wrapper around PHP's eval(). It uses output buffering to capture both returned and printed text. Unlike eval(), we require code to be surrounded by <?php ?> tags; in other words, we evaluate the code as if it were a stand-alone PHP file. Using this wrapper also ensures that the PHP code which is evaluated ca...
function php_eval($code) { global $theme_path, $theme_info, $conf; // Store current theme path. $old_theme_path = $theme_path; // Restore theme_path to the theme, as long as php_eval() executes, // so code evaluated will not see the caller module as the current theme. // If theme info is not initialized g...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aa8d249d8f
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_ancestors/7.x
I need the code for `menu_get_ancestors($parts)` in Drupal 7 (includes/menu.inc). It must do this: Returns the ancestors (and relevant placeholders) for any given path.
For example, the ancestors of node/12345/edit are: - node/12345/edit - node/12345/% - node/%/edit - node/%/% - node/12345 - node/% - node To generate these, we will use binary numbers. Each bit represents a part of the path. If the bit is 1, then it represents the original value while 0 means wildcard. If the path is ...
function menu_get_ancestors($parts) { $number_parts = count($parts); $ancestors = array(); $length = $number_parts - 1; $end = (1 << $number_parts) - 1; $masks = variable_get('menu_masks'); // If the optimized menu_masks array is not available use brute force to get // the correct $ancestors and $placeho...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aa9e8cb688
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_load_links/7.x
Implement `menu_load_links($menu_name)` in PHP for Drupal 7. Required behavior: Returns an array containing all links for a menu.
Parameters: - $menu_name: The name of the menu whose links should be returned. Returns: An array of menu links. File: includes/menu.inc
function menu_load_links($menu_name) { $links = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)) ->fields('ml') ->condition('ml.menu_name', $menu_name) // Order by weight so as to be helpful for menus that are only one level // deep. ->orderBy('weight') ->execute() ->fetch...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aab54682a9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21tracker%21tracker.module/function/tracker_menu/7.x
I need the code for `tracker_menu()` in Drupal 7 (modules/tracker/tracker.module). It must do this: Implements hook_menu().
File: modules/tracker/tracker.module
function tracker_menu() { $items['tracker'] = array( 'title' => 'Recent content', 'page callback' => 'tracker_page', 'access arguments' => array('access content'), 'weight' => 1, 'file' => 'tracker.pages.inc', ); $items['tracker/all'] = array( 'title' => 'All recent content', 'type' =>...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-aabd5fdf91
7
drupal_api_code
https://api.drupal.org/api/drupal/themes%21seven%21template.php/function/seven_preprocess_page/7.x
Implement `seven_preprocess_page(&$vars)` in PHP for Drupal 7. Required behavior: Override or insert variables into the page template.
File: themes/seven/template.php
function seven_preprocess_page(&$vars) { $vars['primary_local_tasks'] = $vars['tabs']; unset($vars['primary_local_tasks']['#secondary']); $vars['secondary_local_tasks'] = array( '#theme' => 'menu_local_tasks', '#secondary' => $vars['tabs']['#secondary'], ); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aacca57732
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.install/function/menu_schema/7.x
I need the code for `menu_schema()` in Drupal 7 (modules/menu/menu.install). It must do this: Implements hook_schema().
File: modules/menu/menu.install
function menu_schema() { $schema['menu_custom'] = array( 'description' => 'Holds definitions for top-level custom menus (for example, Main menu).', 'fields' => array( 'menu_name' => array( 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '', '...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-aaccb62a8d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_field_delete_form/7.x
In Drupal 7, write the function `field_ui_field_delete_form($form, &$form_state, $instance)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Form constructor for removing a field instance from a bundle.
File: modules/field_ui/field_ui.admin.inc
function field_ui_field_delete_form($form, &$form_state, $instance) { $bundle = $instance['bundle']; $entity_type = $instance['entity_type']; $field = field_info_field($instance['field_name']); $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); $form['entity_type'] = array('#type' => 'value',...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aad4713d65
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_update_last_removed/7.x
In Drupal 7, show an example implementation for `hook_update_last_removed()` (modules/system/system.api.php): Return a number which is no longer available as hook_update_N().
If you remove some update functions from your mymodule.install file, you should notify Drupal of those missing functions. This way, Drupal can ensure that no update is accidentally skipped. Implementations of this hook should be placed in a mymodule.install file in the same directory as mymodule.module. Returns: An i...
function hook_update_last_removed() { // We've removed the 5.x-1.x version of mymodule, including database updates. // The next update function is mymodule_update_5200(). return 5103; }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-aad9a26efd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_timezone/7.x
In Drupal 7, write the function `system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL)` (file modules/system/system.module) so that it does the following: Menu callback; Retrieve a JSON object containing a suggested time zone name.
File: modules/system/system.module
function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) { // An abbreviation of "0" passed in the callback arguments should be // interpreted as the empty string. $abbreviation = $abbreviation ? $abbreviation : ''; $timezone = timezone_name_from_abbr($abbreviation, intval($of...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aae02210ce
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7036/7.x
Implement `system_update_7036()` in PHP for Drupal 7. Required behavior: Split the 'access site in maintenance mode' permission from 'administer site configuration'.
File: modules/system/system.install
function system_update_7036() { // Get existing roles that can 'administer site configuration'. $rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer site configuration'))->fetchCol(); // None found. if (empty($rids)) { return; } $insert = db_insert(...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ab1be357e3
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_menu/7.x
Implement `menu_menu()` in PHP for Drupal 7. Required behavior: Implements hook_menu().
File: modules/menu/menu.module
function menu_menu() { $items['admin/structure/menu'] = array( 'title' => 'Menus', 'description' => 'Add new menus to your site, edit existing menus, and rename and reorganize menu links.', 'page callback' => 'menu_overview_page', 'access callback' => 'user_access', 'access arguments' => array('ad...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ab217fdec5
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_attach_form/7.x
In Drupal 7, show an example implementation for `hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode)` (modules/field/field.api.php): Act on field_attach_form().
This hook is invoked after the field module has performed the operation. Implementing modules should alter the $form or $form_state parameters. Parameters: - $entity_type: The type of $entity; for example, 'node' or 'user'. - $entity: The entity for which an edit form is being built. - $form: The form structure where ...
function hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) { // Add a checkbox allowing a given field to be emptied. // See hook_field_attach_submit() for the corresponding processing code. $form['empty_field_foo'] = array( '#type' => 'checkbox', '#title' => t("Empty the 'fiel...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-ab2a011751
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_mass_update/7.x
Implement `node_mass_update($nodes, $updates)` in PHP for Drupal 7. Required behavior: Make mass update of nodes, changing all nodes in the $nodes array to update them with the field values in $updates.
IMPORTANT NOTE: This function is intended to work when called from a form submission handler. Calling it outside of the form submission process may not work correctly. Parameters: - $nodes (array): Array of node nids to update. - $updates (array): Array of key/value pairs with node field names and the value to update ...
function node_mass_update($nodes, $updates) { // We use batch processing to prevent timeout when updating a large number // of nodes. if (count($nodes) > 10) { $batch = array( 'operations' => array( array('_node_mass_update_batch_process', array($nodes, $updates)) ), 'finished' => '_...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ab327c70c0
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_tableselect/7.x
I need the code for `theme_tableselect($variables)` in Drupal 7 (includes/form.inc). It must do this: Returns HTML for a table with radio buttons or checkboxes.
Parameters: - $variables: An associative array containing: - element: An associative array containing the properties and children of the tableselect element. Properties used: #header, #options, #empty, and #js_select. The #options property is an array of selection options; each array element of #options is an array of ...
function theme_tableselect($variables) { $element = $variables['element']; $rows = array(); $header = $element['#header']; if (!empty($element['#options'])) { // Generate a table row for each selectable item in #options. foreach (element_children($element) as $key) { $row = array(); $row['d...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ab3e19ba2d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.api.php/function/hook_menu_delete/7.x
In Drupal 7, show an example implementation for `hook_menu_delete($menu)` (modules/menu/menu.api.php): Respond to a custom menu deletion.
This hook is used to notify modules that a custom menu along with all links contained in it (if any) has been deleted. Contributed modules may use the information to perform actions based on the information entered into the menu system. Parameters: - $menu: An array representing a custom menu: - menu_name: The unique ...
function hook_menu_delete($menu) { // Delete the record from our variable. $my_menus = variable_get('my_module_menus', array()); unset($my_menus[$menu['menu_name']]); variable_set('my_module_menus', $my_menus); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-ab3f95f216
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_in_active_trail/7.x
In Drupal 7, write the function `toolbar_in_active_trail($path)` (file modules/toolbar/toolbar.module) so that it does the following: Checks whether an item is in the active trail.
Useful when using a menu generated by menu_tree_all_data() which does not set the 'in_active_trail' flag on items. Returns: TRUE when path is in the active trail, FALSE if not. File: modules/toolbar/toolbar.module
function toolbar_in_active_trail($path) { $active_paths = &drupal_static(__FUNCTION__); // Gather active paths. if (!isset($active_paths)) { $active_paths = array(); $trail = menu_get_active_trail(); foreach ($trail as $item) { if (!empty($item['href'])) { $active_paths[] = $item['href'...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ab59b65213
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.admin.inc/function/comment_confirm_delete/7.x
I need the code for `comment_confirm_delete($form, &$form_state, $comment)` in Drupal 7 (modules/comment/comment.admin.inc). It must do this: Form builder; Builds the confirmation form for deleting a single comment.
File: modules/comment/comment.admin.inc
function comment_confirm_delete($form, &$form_state, $comment) { $form['#comment'] = $comment; // Always provide entity id in the same form key as in the entity edit form. $form['cid'] = array('#type' => 'value', '#value' => $comment->cid); return confirm_form( $form, t('Are you sure you want to delete ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ab6bb907de
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/openid_normalize/7.x
I need the code for `openid_normalize($identifier)` in Drupal 7 (modules/openid/openid.inc). It must do this: Normalize the given identifier.
The procedure is described in OpenID Authentication 2.0, section 7.2. File: modules/openid/openid.inc
function openid_normalize($identifier) { $methods = module_invoke_all('openid_normalization_method_info'); drupal_alter('openid_normalization_method_info', $methods); // Execute each method in turn, stopping after the first method accepted // the identifier. foreach ($methods as $method) { $result = $met...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ab778fb9a4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_vocabulary_confirm_reset_alphabetical_submit/7.x
In Drupal 7, write the function `taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state)` (file modules/taxonomy/taxonomy.admin.inc) so that it does the following: Submit handler to reset a vocabulary to alphabetical order after confirmation.
File: modules/taxonomy/taxonomy.admin.inc
function taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state) { db_update('taxonomy_term_data') ->fields(array('weight' => 0)) ->condition('vid', $form_state['values']['vid']) ->execute(); drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ab7909deee
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_view_multiple/7.x
In Drupal 7, write the function `node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL)` (file modules/node/node.module) so that it does the following: Constructs a drupal_render() style array from an array of loaded nodes.
Parameters: - $nodes: An array of nodes as returned by node_load_multiple(). - $view_mode: View mode, e.g. 'full', 'teaser'... - $weight: An integer representing the weight of the first node in the list. - $langcode: (optional) A language code to use for rendering. Defaults to NULL which is the global content language ...
function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) { $build = array('nodes' => array()); $entities_by_view_mode = entity_view_mode_prepare('node', $nodes, $view_mode, $langcode); foreach ($entities_by_view_mode as $entity_view_mode => $entities) { field_attach_prepare_vi...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-abb0af0218
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21profile%21profile.module/function/template_preprocess_profile_wrapper/7.x
Implement `template_preprocess_profile_wrapper(&$variables)` in PHP for Drupal 7. Required behavior: Process variables for profile-wrapper.tpl.php.
The $variables array contains the following arguments: - $content File: modules/profile/profile.module
function template_preprocess_profile_wrapper(&$variables) { $variables['current_field'] = ''; if ($field = arg(1)) { $variables['current_field'] = $field; $variables['theme_hook_suggestions'][] = 'profile_wrapper__' . $field; } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-abc6f5b3e8
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.manager.inc/function/update_manager_archive_extract/7.x
I need the code for `update_manager_archive_extract($file, $directory)` in Drupal 7 (modules/update/update.manager.inc). It must do this: Unpacks a downloaded archive file.
Parameters: - $file (string): The filename of the archive you wish to extract. - $directory (string): The directory you wish to extract the archive into. Returns: Archiver The Archiver object used to extract the archive. File: modules/update/update.manager.inc
function update_manager_archive_extract($file, $directory) { $archiver = archiver_get_archiver($file); if (!$archiver) { throw new Exception(t('Cannot extract %file, not a valid archive.', array ('%file' => $file))); } // Remove the directory if it exists, otherwise it might contain a mixture of // old f...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ac366d3b52
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/_field_write_instance/7.x
I need the code for `_field_write_instance($instance, $update = FALSE)` in Drupal 7 (modules/field/field.crud.inc). It must do this: Stores an instance record in the field configuration database.
Parameters: - $instance: An instance structure. - $update: Whether this is a new or existing instance. File: modules/field/field.crud.inc
function _field_write_instance($instance, $update = FALSE) { $field = field_read_field($instance['field_name']); $field_type = field_info_field_types($field['type']); // Set defaults. $instance += array( 'settings' => array(), 'display' => array(), 'widget' => array(), 'required' => FALSE, ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ac4174f908
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21path%21path.module/function/path_node_insert/7.x
I need the code for `path_node_insert($node)` in Drupal 7 (modules/path/path.module). It must do this: Implements hook_node_insert().
File: modules/path/path.module
function path_node_insert($node) { if (isset($node->path) && isset($node->path['alias'])) { $path = $node->path; $path['alias'] = trim($path['alias']); // Only save a non-empty alias. if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $langcode = entity_language('n...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ac47865616
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_random_bytes/7.x
I need the code for `drupal_random_bytes($count)` in Drupal 7 (includes/bootstrap.inc). It must do this: Returns a string of highly randomized bytes (over the full 8-bit range).
On PHP 7 and later, this function is a wrapper around the built-in PHP function random_bytes(). If that function does not exist or cannot find an appropriate source of randomness, this function is better than simply calling mt_rand() or any other built-in PHP function because it can return a long string of bytes (compa...
function drupal_random_bytes($count) { if (function_exists('random_bytes')) { try { return random_bytes($count); } catch (Exception $e) { // An appropriate source of randomness could not be found. Fall back to a // less secure implementation. } } // $random_state does not use d...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ac52110e8c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_mail/7.x
Implement `system_mail($key, &$message, $params)` in PHP for Drupal 7. Required behavior: Implements hook_mail().
File: modules/system/system.module
function system_mail($key, &$message, $params) { $context = $params['context']; $subject = token_replace($context['subject'], $context); $body = token_replace($context['message'], $context); $message['subject'] .= str_replace(array("\r", "\n"), '', $subject); $message['body'][] = $body; }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ac53fafac6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.install/function/image_update_7003/7.x
I need the code for `image_update_7003()` in Drupal 7 (modules/image/image.install). It must do this: Remove the variables that set alt and title length since they were not used for database column size and could cause PDO exceptions.
File: modules/image/image.install
function image_update_7003() { variable_del('image_alt_length'); variable_del('image_title_length'); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ac7f8807f2
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7086/7.x
In Drupal 7, write the function `system_update_7086()` (file modules/system/system.install) so that it does the following: Prepare the schema and data of the sessions table for hashed session ids.
File: modules/system/system.install
function system_update_7086() { // Update the session ID fields' description. $spec = array( 'description' => "A session ID (hashed). The value is generated by Drupal's session handlers.", 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, ); db_drop_primary_key('sessions'); db_change_f...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ac86ac6d33
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/form_execute_handlers/7.x
I need the code for `form_execute_handlers($type, &$form, &$form_state)` in Drupal 7 (includes/form.inc). It must do this: Executes custom validation and submission handlers for a given form.
Button-specific handlers are checked first. If none exist, the function falls back to form-level handlers. Parameters: - $type: The type of handler to execute. 'validate' or 'submit' are the defaults used by Form API. - $form: An associative array containing the structure of the form. - $form_state: A keyed array cont...
function form_execute_handlers($type, &$form, &$form_state) { $return = FALSE; // If there was a button pressed, use its handlers. if (isset($form_state[$type . '_handlers'])) { $handlers = $form_state[$type . '_handlers']; } // Otherwise, check for a form-level handler. elseif (isset($form['#' . $type]...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ac9c5e9467
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_progress_bar/7.x
In Drupal 7, write the function `theme_progress_bar($variables)` (file includes/theme.inc) so that it does the following: Returns HTML for a progress bar.
Note that the core Batch API uses this only for non-JavaScript batch jobs. Parameters: - $variables: An associative array containing: - percent: The percentage of the progress. - message: A string containing information to be displayed. File: includes/theme.inc
function theme_progress_bar($variables) { $output = '<div id="progress" class="progress">'; $output .= '<div class="bar"><div class="filled" style="width: ' . $variables['percent'] . '%"></div></div>'; $output .= '<div class="percentage">' . $variables['percent'] . '%</div>'; $output .= '<div class="message">' ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-acb02ec731
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21lock.inc/function/lock_wait/7.x
Implement `lock_wait($name, $delay = 30)` in PHP for Drupal 7. Required behavior: Wait for a lock to be available.
This function may be called in a request that fails to acquire a desired lock. This will block further execution until the lock is available or the specified delay in seconds is reached. This should not be used with locks that are acquired very frequently, since the lock is likely to be acquired again by a different re...
function lock_wait($name, $delay = 30) { // Pause the process for short periods between calling // lock_may_be_available(). This prevents hitting the database with constant // database queries while waiting, which could lead to performance issues. // However, if the wait period is too long, there is the potenti...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-acd0af653e
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21session.inc/function/_drupal_session_write/7.x
Implement `_drupal_session_write($sid, $value)` in PHP for Drupal 7. Required behavior: Writes an entire session to the database (internal use only).
This function is registered with session_set_save_handler() to support database-backed sessions. This function is an internal function and must not be called directly. Doing so may result in corrupted session data or other unexpected behavior. Session data must always be accessed via the $_SESSION superglobal. Parame...
function _drupal_session_write($sid, $value) { global $user, $is_https; // The exception handler is not active at this point, so we need to do it // manually. try { if (!drupal_save_session()) { // We don't have anything to do if we are not allowed to save the session. return TRUE; } /...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-acdba8bbc8
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_revision_delete_confirm_submit/7.x
In Drupal 7, write the function `node_revision_delete_confirm_submit($form, &$form_state)` (file modules/node/node.pages.inc) so that it does the following: Form submission handler for node_revision_delete_confirm().
File: modules/node/node.pages.inc
function node_revision_delete_confirm_submit($form, &$form_state) { $node_revision = $form['#node_revision']; node_revision_delete($node_revision->vid); watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ace3d0ec2d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_field_delete_field/7.x
Implement `image_field_delete_field($field)` in PHP for Drupal 7. Required behavior: Implements hook_field_delete_field().
File: modules/image/image.module
function image_field_delete_field($field) { if ($field['type'] != 'image') { return; } // The value of a managed_file element can be an array if #extended == TRUE. $fid = (is_array($field['settings']['default_image']) ? $field['settings']['default_image']['fid'] : $field['settings']['default_image']); if...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ace7f778fa
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21session.inc/function/_drupal_session_garbage_collection/7.x
In Drupal 7, write the function `_drupal_session_garbage_collection($lifetime)` (file includes/session.inc) so that it does the following: Session handler assigned by session_set_save_handler().
Cleans up stalled sessions. Parameters: - $lifetime: The value of session.gc_maxlifetime, passed by PHP. Sessions not updated for more than $lifetime seconds will be removed. File: includes/session.inc
function _drupal_session_garbage_collection($lifetime) { // Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough // value. For example, if you want user sessions to stay in your database // for three weeks before deleting them, you need to set gc_maxlifetime // to '1814400'. At that value, onl...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ace9d91ff4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_node_search_result/7.x
In Drupal 7, write the function `comment_node_search_result($node)` (file modules/comment/comment.module) so that it does the following: Implements hook_node_search_result().
Formats a comment count string and returns it, for display with search results. File: modules/comment/comment.module
function comment_node_search_result($node) { // Do not make a string if comments are hidden. if (user_access('access comments') && $node->comment != COMMENT_NODE_HIDDEN) { $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField(); ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-acea67960f
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_group_css/7.x
I need the code for `drupal_group_css($css)` in Drupal 7 (includes/common.inc). It must do this: Default callback to group CSS items.
This function arranges the CSS items that are in the #items property of the styles element into groups. Arranging the CSS items into groups serves two purposes. When aggregation is enabled, files within a group are aggregated into a single file, significantly improving page loading performance by minimizing network tra...
function drupal_group_css($css) { $groups = array(); // If a group can contain multiple items, we track the information that must // be the same for each item in the group, so that when we iterate the next // item, we can determine if it can be put into the current group, or if a // new group needs to be made...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ad0472d5f9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21trigger%21trigger.install/function/trigger_install/7.x
I need the code for `trigger_install()` in Drupal 7 (modules/trigger/trigger.install). It must do this: Implements hook_install().
File: modules/trigger/trigger.install
function trigger_install() { // Do initial synchronization of actions in code and the database. actions_synchronize(); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ad069b832f
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/_system_modules_build_row/7.x
In Drupal 7, write the function `_system_modules_build_row($info, $extra)` (file modules/system/system.admin.inc) so that it does the following: Build a table row for the system modules page.
File: modules/system/system.admin.inc
function _system_modules_build_row($info, $extra) { // Add in the defaults. $extra += array( 'requires' => array(), 'required_by' => array(), 'disabled' => FALSE, 'enabled' => FALSE, 'links' => array(), ); $form = array( '#tree' => TRUE, ); // Set the basic properties. $form['name'...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ad0c8e6b74
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_help/7.x
I need the code for `forum_help($path, $arg)` in Drupal 7 (modules/forum/forum.module). It must do this: Implements hook_help().
File: modules/forum/forum.module
function forum_help($path, $arg) { switch ($path) { case 'admin/help#forum': $output = ''; $output .= '<h3>' . t('About') . '</h3>'; $output .= '<p>' . t('The Forum module lets you create threaded discussion forums with functionality similar to other message board systems. Forums are useful beca...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ad132e3ef2
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/_image_field_resolution_validate/7.x
I need the code for `_image_field_resolution_validate($element, &$form_state)` in Drupal 7 (modules/image/image.field.inc). It must do this: Element validate function for resolution fields.
File: modules/image/image.field.inc
function _image_field_resolution_validate($element, &$form_state) { if (!empty($element['x']['#value']) || !empty($element['y']['#value'])) { foreach (array('x', 'y') as $dimension) { $value = $element[$dimension]['#value']; if (!is_numeric($value)) { form_error($element[$dimension], t('Height...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ad17fc506b
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_import_locales_remaining/7.x
Implement `install_import_locales_remaining(&$install_state)` in PHP for Drupal 7. Required behavior: Installation task; import remaining languages via a batch process.
Parameters: - $install_state: An array of information about the current installation state. Returns: The batch definition, if there are language files to import. File: includes/install.core.inc
function install_import_locales_remaining(&$install_state) { include_once DRUPAL_ROOT . '/includes/locale.inc'; // Collect files to import for this language. Skip components already covered // in the initial batch set. $install_locale = $install_state['parameters']['locale']; $batch = locale_batch_by_language...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ad2c071117
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_display_alter/7.x
In Drupal 7, show an example implementation for `hook_field_display_alter(&$display, $context)` (modules/field/field.api.php): Alters the display settings of a field before it gets displayed.
Note that instead of hook_field_display_alter(), which is called for all fields on all entity types, hook_field_display_ENTITY_TYPE_alter() may be used to alter display settings for fields on a specific entity type only. This hook is called once per field per displayed entity. If the result of the hook involves readin...
function hook_field_display_alter(&$display, $context) { // Leave field labels out of the search index. // Note: The check against $context['entity_type'] == 'node' could be avoided // by using hook_field_display_node_alter() instead of // hook_field_display_alter(), resulting in less function calls when // r...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-ad2c3c080c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_preprocess_field/7.x
In Drupal 7, write the function `rdf_preprocess_field(&$variables)` (file modules/rdf/rdf.module) so that it does the following: Implements MODULE_preprocess_HOOK().
File: modules/rdf/rdf.module
function rdf_preprocess_field(&$variables) { $element = $variables['element']; $mapping = rdf_mapping_load($element['#entity_type'], $element['#bundle']); $field_name = $element['#field_name']; if (!empty($mapping) && !empty($mapping[$field_name])) { foreach ($element['#items'] as $delta => $item) { ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ad53f20d52
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_array_merge_deep_array/7.x
Implement `drupal_array_merge_deep_array($arrays)` in PHP for Drupal 7. Required behavior: Merges multiple arrays, recursively, and returns the merged array.
This function is equivalent to drupal_array_merge_deep(), except the input arrays are passed as a single array parameter rather than a variable parameter list. The following are equivalent: - drupal_array_merge_deep($a, $b); - drupal_array_merge_deep_array(array($a, $b)); The following are also equivalent: - call_use...
function drupal_array_merge_deep_array($arrays) { $result = array(); foreach ($arrays as $array) { foreach ($array as $key => $value) { // Renumber integer keys as array_merge_recursive() does. Note that PHP // automatically converts array keys that are integer strings (e.g., '1') // to integ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ad589a0e70
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21image.inc/function/image_scale/7.x
In Drupal 7, write the function `image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE)` (file includes/image.inc) so that it does the following: Scales an image while maintaining aspect ratio.
The resulting image can be smaller for one or both target dimensions. Parameters: - $image: An image object returned by image_load(). - $width: The target width, in pixels. If this value is NULL then the scaling will be based only on the height value. - $height: The target height, in pixels. If this value is NULL then...
function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) { $dimensions = $image->info; // Scale the dimensions - if they don't change then just return success. if (!image_dimensions_scale($dimensions, $width, $height, $upscale)) { return TRUE; } return image_resize($image, ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ad5902660d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_access_records/7.x
In Drupal 7, show an example implementation for `hook_node_access_records($node)` (modules/node/node.api.php): Set permissions for a node to be written to the database.
When a node is saved, a module implementing hook_node_access_records() will be asked if it is interested in the access permissions for a node. If it is interested, it must respond with an array of permissions arrays for that node. Node access grants apply regardless of the published or unpublished status of the node. ...
function hook_node_access_records($node) { // We only care about the node if it has been marked private. If not, it is // treated just like any other node and we completely ignore it. if ($node->private) { $grants = array(); // Only published nodes should be viewable to all users. If we allow access /...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-ad88ccbe83
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_user_cancel/7.x
In Drupal 7, write the function `node_user_cancel($edit, $account, $method)` (file modules/node/node.module) so that it does the following: Implements hook_user_cancel().
File: modules/node/node.module
function node_user_cancel($edit, $account, $method) { switch ($method) { case 'user_cancel_block_unpublish': // Unpublish nodes (current revisions). module_load_include('inc', 'node', 'node.admin'); $nodes = db_select('node', 'n') ->fields('n', array('nid')) ->condition('uid', $a...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ad98a3ab87
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.install/function/field_update_7004/7.x
Implement `field_update_7004()` in PHP for Drupal 7. Required behavior: Grant the new "administer fields" permission to trusted users.
File: modules/field/field.install
function field_update_7004() { // Assign the permission to anyone that already has a trusted core permission // that would have previously let them administer fields on an entity type. $rids = array(); $permissions = array( 'administer site configuration', 'administer content types', 'administer use...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ada8ad4772
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_show_disabled/7.x
In Drupal 7, write the function `dashboard_show_disabled()` (file modules/dashboard/dashboard.module) so that it does the following: Ajax callback: Shows disabled blocks in the dashboard customization mode.
File: modules/dashboard/dashboard.module
function dashboard_show_disabled() { global $theme_key; // Blocks are not necessarily initialized at this point. $blocks = _block_rehash(); // Limit the list to blocks that are marked as disabled for the dashboard. foreach ($blocks as $key => $block) { if ($block['theme'] != $theme_key || $block['region...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-adc7de11fe
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.tokens.inc/function/comment_token_info/7.x
I need the code for `comment_token_info()` in Drupal 7 (modules/comment/comment.tokens.inc). It must do this: Implements hook_token_info().
File: modules/comment/comment.tokens.inc
function comment_token_info() { $type = array( 'name' => t('Comments'), 'description' => t('Tokens for comments posted on the site.'), 'needs-data' => 'comment', ); // Comment-related tokens for nodes $node['comment-count'] = array( 'name' => t("Comment count"), 'description' => t("The numb...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-add6d1ef0a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21announcements_feed%21announcements_feed.inc/function/announcements_feed_is_relevant_item/7.x
Implement `announcements_feed_is_relevant_item($version)` in PHP for Drupal 7. Required behavior: Check whether the version given is relevant to the Drupal version used.
Parameters: - $version (string): Version to check. Returns (bool): Return TRUE if the version matches Drupal version. File: modules/announcements_feed/announcements_feed.inc
function announcements_feed_is_relevant_item($version) { if ($version == '*') { return TRUE; } // Split the version if received in || formats. $version_patterns = '/\|\|/'; $all_versions = preg_split($version_patterns, $version); // The operation is optional and defaults to equals. $p_op = '(?P<operat...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-add73aa4c9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_get_namespaces/7.x
I need the code for `rdf_get_namespaces()` in Drupal 7 (modules/rdf/rdf.module). It must do this: Returns an array of RDF namespaces defined in modules that implement hook_rdf_namespaces().
File: modules/rdf/rdf.module
function rdf_get_namespaces() { $rdf_namespaces = module_invoke_all('rdf_namespaces'); // module_invoke_all() uses array_merge_recursive() which might return nested // arrays if several modules redefine the same prefix multiple times. We need // to ensure the array of namespaces is flat and only contains string...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ade59489af
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_date_formats/7.x
In Drupal 7, write the function `system_date_formats()` (file modules/system/system.module) so that it does the following: Implements hook_date_formats().
File: modules/system/system.module
function system_date_formats() { include_once DRUPAL_ROOT . '/includes/date.inc'; return system_default_date_formats(); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-adf20d7afb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.api.php/function/hook_rdf_mapping/7.x
Give me the example code for `hook_rdf_mapping()` in Drupal 7. Hook description: Allow modules to define RDF mappings for field bundles.
Modules defining their own field bundles can specify which RDF semantics should be used to annotate these bundles. These mappings are then used for automatic RDFa output in the HTML code. Returns: A list of mapping structures, where each mapping is an associative array: - type: The name of an entity type (e.g., 'node'...
function hook_rdf_mapping() { return array( array( 'type' => 'node', 'bundle' => 'blog', 'mapping' => array( 'rdftype' => array('sioct:Weblog'), 'title' => array( 'predicates' => array('dc:title'), ), 'created' => array( 'predicates' => array('...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-ae12e818d7
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_updaters/7.x
Implement `drupal_get_updaters()` in PHP for Drupal 7. Required behavior: Assembles the Drupal Updater registry.
An Updater is a class that knows how to update various parts of the Drupal file system, for example to update modules that have newer releases, or to install a new theme. Returns: The Drupal Updater class registry. File: includes/common.inc
function drupal_get_updaters() { $updaters = &drupal_static(__FUNCTION__); if (!isset($updaters)) { $updaters = module_invoke_all('updater_info'); drupal_alter('updater_info', $updaters); uasort($updaters, 'drupal_sort_weight'); } return $updaters; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ae16209199
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_file_download_access/7.x
I need the code for `user_file_download_access($field, $entity_type, $entity)` in Drupal 7 (modules/user/user.module). It must do this: Implements hook_file_download_access().
File: modules/user/user.module
function user_file_download_access($field, $entity_type, $entity) { if ($entity_type == 'user') { return user_view_access($entity); } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ae1826fd8a
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_find_locales/7.x
Implement `install_find_locales($profilename)` in PHP for Drupal 7. Required behavior: Find all .po files for the current profile.
File: includes/install.core.inc
function install_find_locales($profilename) { $locales = file_scan_directory('./profiles/' . $profilename . '/translations', '/\.po$/', array('recurse' => FALSE)); array_unshift($locales, (object) array('name' => 'en')); foreach ($locales as $key => $locale) { // The locale (file name) might be drupal-7.2.cs....
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ae1d12935b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dblog%21dblog.admin.inc/function/dblog_filter_form_validate/7.x
In Drupal 7, write the function `dblog_filter_form_validate($form, &$form_state)` (file modules/dblog/dblog.admin.inc) so that it does the following: Form validation handler for dblog_filter_form().
File: modules/dblog/dblog.admin.inc
function dblog_filter_form_validate($form, &$form_state) { if ($form_state['values']['op'] == t('Filter') && empty($form_state['values']['type']) && empty($form_state['values']['severity'])) { form_set_error('type', t('You must select something to filter by.')); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ae2aa85346
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_storage_purge_field_instance/7.x
Give me the example code for `hook_field_storage_purge_field_instance($instance)` in Drupal 7. Hook description: Remove field storage information when a field instance is purged.
Called from field_purge_instance() to allow the field storage module to remove field instance information when a field instance is being purged. Parameters: - $instance: The instance being purged. File: modules/field/field.api.php
function hook_field_storage_purge_field_instance($instance) { db_delete('my_module_field_instance_info') ->condition('id', $instance['id']) ->execute(); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-ae30f0994e
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_deliver_html_page/7.x
I need the code for `drupal_deliver_html_page($page_callback_result)` in Drupal 7 (includes/common.inc). It must do this: Packages and sends the result of a page callback to the browser as HTML.
Parameters: - $page_callback_result: The result of a page callback. Can be one of: - NULL: to indicate no content. - An integer menu status constant: to indicate an error condition. - A string of HTML content. - A renderable array of content. File: includes/common.inc
function drupal_deliver_html_page($page_callback_result) { // Emit the correct charset HTTP header, but not if the page callback // result is NULL, since that likely indicates that it printed something // in which case, no further headers may be sent, and not if code running // for this page request has already...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ae5ab65e6a
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/_drupal_http_use_proxy/7.x
In Drupal 7, write the function `_drupal_http_use_proxy($host)` (file includes/common.inc) so that it does the following: Helper function for determining hosts excluded from needing a proxy.
Returns: TRUE if a proxy should be used for this host. File: includes/common.inc
function _drupal_http_use_proxy($host) { $proxy_exceptions = variable_get('proxy_exceptions', array('localhost', '127.0.0.1')); return !in_array(strtolower($host), $proxy_exceptions, TRUE); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ae61e27936
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_preprocess_html/7.x
Implement `overlay_preprocess_html(&$variables)` in PHP for Drupal 7. Required behavior: Implements hook_preprocess_html().
If the current page request is inside the overlay, add appropriate classes to the <body> element, and simplify the page title. File: modules/overlay/overlay.module
function overlay_preprocess_html(&$variables) { if (overlay_get_mode() == 'child') { // Add overlay class, so themes can react to being displayed in the overlay. $variables['classes_array'][] = 'overlay'; } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ae634944f4
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_form/7.x
Implement `theme_form($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a form.
Parameters: - $variables: An associative array containing: - element: An associative array containing the properties of the element. Properties used: #action, #method, #attributes, #children File: includes/form.inc
function theme_form($variables) { $element = $variables['element']; if (isset($element['#action'])) { $element['#attributes']['action'] = drupal_strip_dangerous_protocols($element['#action']); } element_set_attributes($element, array('method', 'id')); if (empty($element['#attributes']['accept-charset'])) ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aeb858fd46
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_themes_disabled/7.x
In Drupal 7, write the function `update_themes_disabled($themes)` (file modules/update/update.module) so that it does the following: Implements hook_themes_disabled().
If themes are disabled, we invalidate the cache of available updates. File: modules/update/update.module
function update_themes_disabled($themes) { // Clear all update module caches. _update_cache_clear(); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-aec1f65be9
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_rebuild/7.x
Implement `menu_rebuild()` in PHP for Drupal 7. Required behavior: Populates the database tables used by various menu functions.
This function will clear and populate the {menu_router} table, add entries to {menu_links} for new router items, and then remove stale items from {menu_links}. If called from update.php or install.php, it will also schedule a call to itself on the first real page load from menu_execute_active_handler(), because the mai...
function menu_rebuild() { if (!lock_acquire('menu_rebuild')) { // Wait for another request that is already doing this work. // We choose to block here since otherwise the router item may not // be available in menu_execute_active_handler() resulting in a 404. lock_wait('menu_rebuild'); if (_menu_...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-aec2c0fd1f
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/format_username/7.x
Implement `format_username($account)` in PHP for Drupal 7. Required behavior: Format a username.
This is also the label callback implementation of callback_entity_info_label() for user_entity_info(). By default, the passed-in object's 'name' property is used if it exists, or else, the site-defined value for the 'anonymous' variable. However, a module may override this by implementing hook_username_alter(&$name, $...
function format_username($account) { $name = !empty($account->name) ? $account->name : variable_get('anonymous', t('Anonymous')); drupal_alter('username', $name, $account); return $name; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-af0ae8a021
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.module/function/_field_ui_view_mode_menu_access/7.x
I need the code for `_field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $access_callback)` in Drupal 7 (modules/field_ui/field_ui.module). It must do this: Menu access callback for the 'view mode display settings' pages.
File: modules/field_ui/field_ui.module
function _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $access_callback) { // It's good practice to call func_get_args() at the beginning of a function // to avoid problems with function parameters being modified later. The // behavior of func_get_args() changed in PHP7. // @see https://www...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-af3da77e22
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21profile%21profile.module/function/profile_category_access/7.x
I need the code for `profile_category_access($account, $category)` in Drupal 7 (modules/profile/profile.module). It must do this: Menu item access callback - check if a user has access to a profile category.
File: modules/profile/profile.module
function profile_category_access($account, $category) { if (user_access('administer users') && $account->uid > 0) { return TRUE; } else { $category_visible = (bool) db_query_range('SELECT 1 FROM {profile_field} WHERE category = :category AND visibility <> :visibility', 0, 1, array( ':category' => $c...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-af3f907dcd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.install/function/node_update_7002/7.x
In Drupal 7, write the function `node_update_7002()` (file modules/node/node.install) so that it does the following: Extend the node_promote_status index to include all fields required for the node page query.
File: modules/node/node.install
function node_update_7002() { db_drop_index('node', 'node_promote_status'); db_add_index('node', 'node_frontpage', array('promote', 'status', 'sticky', 'created')); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-af5f560b10
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_insert/7.x
In Drupal 7, show an example implementation for `hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)` (modules/field/field.api.php): Define custom insert behavior for this module's field data.
This hook is invoked from field_attach_insert() on the module that defines a field, during the process of inserting an entity object (node, taxonomy term, etc.). It is invoked just before the data for this field on the particular entity object is inserted into field storage. Only field modules that are storing or track...
function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) { $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 's...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-af7430fc4b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.api.php/function/hook_image_default_styles/7.x
In Drupal 7, show an example implementation for `hook_image_default_styles()` (modules/image/image.api.php): Provide module-based image styles for reuse throughout Drupal.
This hook allows your module to provide image styles. This may be useful if you require images to fit within exact dimensions. Note that you should attempt to re-use the default styles provided by Image module whenever possible, rather than creating image styles that are specific to your module. Image provides the styl...
function hook_image_default_styles() { $styles = array(); $styles['mymodule_preview'] = array( 'label' => 'My module preview', 'effects' => array( array( 'name' => 'image_scale', 'data' => array('width' => 400, 'height' => 400, 'upscale' => 1), 'weight' => 0, ), ar...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-af830966f8
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_exit/7.x
I need the code for `overlay_exit()` in Drupal 7 (modules/overlay/overlay.module). It must do this: Implements hook_exit().
When viewing an overlay child page, check if we need to trigger a refresh of the supplemental regions of the overlay on the next page request. File: modules/overlay/overlay.module
function overlay_exit() { // Check that we are in an overlay child page. Note that this should never // return TRUE on a cached page view, since the child mode is not set until // overlay_init() is called. if (overlay_get_mode() == 'child') { // Load any markup that was stored earlier in the page request, v...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-af91a36475
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7018/7.x
In Drupal 7, write the function `user_update_7018()` (file modules/user/user.install) so that it does the following: Ensure there is an index on {users}.picture.
File: modules/user/user.install
function user_update_7018() { if (!db_index_exists('users', 'picture')) { db_add_index('users', 'picture', array('picture')); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-af938a7beb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_uri/7.x
I need the code for `forum_uri($forum)` in Drupal 7 (modules/forum/forum.module). It must do this: Implements callback_entity_info_uri().
Entity URI callback used in forum_entity_info_alter(). File: modules/forum/forum.module
function forum_uri($forum) { return array( 'path' => 'forum/' . $forum->tid, ); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-af97fbd8f6
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/form_state_values_clean/7.x
I need the code for `form_state_values_clean(&$form_state)` in Drupal 7 (includes/form.inc). It must do this: Removes internal Form API elements and buttons from submitted form values.
This function can be used when a module wants to store all submitted form values, for example, by serializing them into a single database column. In such cases, all internal Form API values and all form button elements should not be contained, and this function allows to remove them before the module proceeds to storag...
function form_state_values_clean(&$form_state) { // Remove internal Form API values. unset($form_state['values']['form_id'], $form_state['values']['form_token'], $form_state['values']['form_build_id'], $form_state['values']['op']); // Remove button values. // form_builder() collects all button elements in a fo...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-afa9a75653
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21theme.maintenance.inc/function/theme_install_page/7.x
In Drupal 7, write the function `theme_install_page($variables)` (file includes/theme.maintenance.inc) so that it does the following: Returns HTML for the installation page.
Note: this function is not themeable. Parameters: - $variables: An associative array containing: - content: The page content to show. File: includes/theme.maintenance.inc
function theme_install_page($variables) { drupal_add_http_header('Content-Type', 'text/html; charset=utf-8'); return theme('maintenance_page', $variables); }
[ "code-task", "function" ]
2026-09-30T00:00:00