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-e54c407db5
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_update/7.x
In Drupal 7, show an example implementation for `hook_update($node)` (modules/node/node.api.php): Respond to updates to a node.
This is a node-type-specific hook, which is invoked only for the node type being affected. See Parameters: - $node: The node that is being updated. File: modules/node/node.api.php
function hook_update($node) { db_update('mytable') ->fields(array('extra' => $node->extra)) ->condition('nid', $node->nid) ->execute(); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-e54f87d8ec
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/watchdog/7.x
I need the code for `watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)` in Drupal 7 (includes/bootstrap.inc). It must do this: Logs a system message.
Parameters: - $type: The category to which this message belongs. Can be any string, but the general practice is to use the name of the module calling watchdog(). - $message: The message to store in the log. Keep $message translatable by not concatenating dynamic values into it! Variables in the message should be added ...
function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) { global $user, $base_root; static $in_error_state = FALSE; // It is possible that the error handling will itself trigger an error. In that case, we could // end up in an infinite loop. To avoid that, we implem...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e576034d8f
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_theme/7.x
Implement `rdf_theme()` in PHP for Drupal 7. Required behavior: Implements hook_theme().
File: modules/rdf/rdf.module
function rdf_theme() { return array( 'rdf_template_variable_wrapper' => array( 'variables' => array('content' => NULL, 'attributes' => array(), 'context' => array(), 'inline' => TRUE), ), 'rdf_metadata' => array( 'variables' => array('metadata' => array()), ), ); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e57f2e01ff
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_tree_check_access/7.x
Implement `_menu_tree_check_access(&$tree)` in PHP for Drupal 7. Required behavior: Sorts the menu tree and recursively checks access for each item.
File: includes/menu.inc
function _menu_tree_check_access(&$tree) { $new_tree = array(); foreach ($tree as $key => $v) { $item = &$tree[$key]['link']; _menu_link_translate($item); if ($item['access'] || ($item['in_active_trail'] && strpos($item['href'], '%') !== FALSE)) { if ($tree[$key]['below']) { _menu_tree_che...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e5a1cd1bcb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_help/7.x
Implement `update_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help().
File: modules/update/update.module
function update_help($path, $arg) { switch ($path) { case 'admin/reports/updates': return '<p>' . t('Here you can find information about available updates for your installed modules and themes. Note that each module or theme is part of a "project", which may or may not have the same name, and might include ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e5b73c3ce6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21locale%21locale.install/function/locale_update_7001/7.x
I need the code for `locale_update_7001()` in Drupal 7 (modules/locale/locale.install). It must do this: Upgrade language negotiation settings.
File: modules/locale/locale.install
function locale_update_7001() { require_once DRUPAL_ROOT . '/includes/language.inc'; require_once DRUPAL_ROOT . '/includes/locale.inc'; require_once DRUPAL_ROOT . '/modules/locale/locale.module'; switch (variable_get('language_negotiation', 0)) { // LANGUAGE_NEGOTIATION_NONE. case 0: $negotiation...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e5cc627f63
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/options_field_widget_settings_form/7.x
I need the code for `options_field_widget_settings_form($field, $instance)` in Drupal 7 (modules/field/modules/options/options.module). It must do this: Implements hook_field_widget_settings_form().
File: modules/field/modules/options/options.module
function options_field_widget_settings_form($field, $instance) { $form = array(); if ($instance['widget']['type'] == 'options_onoff') { $form['display_label'] = array( '#type' => 'checkbox', '#title' => t('Use field label instead of the "On value" as label'), '#default_value' => $instance['wid...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e5cfac36f0
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21locale.inc/function/locale_language_from_user/7.x
Implement `locale_language_from_user($languages)` in PHP for Drupal 7. Required behavior: Identify language from the user preferences.
Parameters: - $languages: An array of valid language objects. Returns: A valid language code on success, FALSE otherwise. File: includes/locale.inc
function locale_language_from_user($languages) { // User preference (only for logged users). global $user; if ($user->uid) { return $user->language; } // No language preference from the user. return FALSE; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e5d2ca4b7a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21number%21number.module/function/number_field_presave/7.x
Implement `number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)` in PHP for Drupal 7. Required behavior: Implements hook_field_presave().
File: modules/field/modules/number/number.module
function number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { if ($field['type'] == 'number_decimal') { // Let PHP round the value to ensure consistent behavior across storage // backends. foreach ($items as $delta => $item) { if (isset($item['value'])) { $ite...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e5d3d31459
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.manager.inc/function/update_manager_install_form_submit/7.x
I need the code for `update_manager_install_form_submit($form, &$form_state)` in Drupal 7 (modules/update/update.manager.inc). It must do this: Form submission handler for update_manager_install_form().
Either downloads the file specified in the URL to a temporary cache, or uploads the file attached to the form, then attempts to extract the archive into a temporary location and verify it. Instantiate the appropriate Updater class for this project and make sure it is not already installed in the live webroot. If everyt...
function update_manager_install_form_submit($form, &$form_state) { if ($form_state['values']['project_url']) { $field = 'project_url'; $local_cache = update_manager_file_get($form_state['values']['project_url']); if (!$local_cache) { form_set_error($field, t('Unable to retrieve Drupal project from %...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e5e06b97a4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_formatter_info/7.x
In Drupal 7, write the function `file_field_formatter_info()` (file modules/file/file.field.inc) so that it does the following: Implements hook_field_formatter_info().
File: modules/file/file.field.inc
function file_field_formatter_info() { return array( 'file_default' => array( 'label' => t('Generic file'), 'field types' => array('file'), ), 'file_table' => array( 'label' => t('Table of files'), 'field types' => array('file'), ), 'file_url_plain' => array( 'label' ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e5ed192669
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_begin/7.x
I need the code for `openid_begin($claimed_id, $return_to = '', $form_values = array())` in Drupal 7 (modules/openid/openid.module). It must do this: The initial step of OpenID authentication responsible for the following: - Perform discovery on the claimed OpenID. - If possible, create an association with the Provider...
Parameters: - $claimed_id: The OpenID to authenticate - $return_to: The endpoint to return to from the OpenID Provider File: modules/openid/openid.module
function openid_begin($claimed_id, $return_to = '', $form_values = array()) { module_load_include('inc', 'openid'); $service = NULL; $claimed_id = openid_normalize($claimed_id); $discovery = openid_discovery($claimed_id); if (!empty($discovery['services'])) { $service = _openid_select_service($discovery...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e6130d4aa4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_time_zones/7.x
I need the code for `system_time_zones($blank = NULL)` in Drupal 7 (modules/system/system.module). It must do this: Generate an array of time zones and their local time&date.
Parameters: - $blank: If evaluates true, prepend an empty time zone option to the array. File: modules/system/system.module
function system_time_zones($blank = NULL) { $zonelist = timezone_identifiers_list(); $zones = $blank ? array('' => t('- None selected -')) : array(); foreach ($zonelist as $zone) { // Because many time zones exist in PHP only for backward compatibility // reasons and should not be used, the list is filter...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e615a8e583
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.parser.inc/function/aggregator_element_data/7.x
In Drupal 7, write the function `aggregator_element_data($parser, $data)` (file modules/aggregator/aggregator.parser.inc) so that it does the following: Performs an action when data is encountered.
Callback function used by xml_parse() within aggregator_parse_feed(). File: modules/aggregator/aggregator.parser.inc
function aggregator_element_data($parser, $data) { global $channel, $element, $items, $item, $image, $tag; $items += array($item => array()); switch ($element) { case 'item': $items[$item] += array($tag => ''); $items[$item][$tag] .= $data; break; case 'image': case 'logo': $im...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e617012572
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_cron/7.x
I need the code for `aggregator_cron()` in Drupal 7 (modules/aggregator/aggregator.module). It must do this: Implements hook_cron().
Queues news feeds for updates once their refresh interval has elapsed. File: modules/aggregator/aggregator.module
function aggregator_cron() { $result = db_query('SELECT * FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array( ':time' => REQUEST_TIME, ':never' => AGGREGATOR_CLEAR_NEVER )); $queue = DrupalQueue::get('aggregator_feeds'); foreach ($result as $feed) { i...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e6256da525
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.install/function/forum_update_7000/7.x
In Drupal 7, write the function `forum_update_7000()` (file modules/forum/forum.install) so that it does the following: Add new index to forum table.
File: modules/forum/forum.install
function forum_update_7000() { db_drop_index('forum', 'nid'); db_add_index('forum', 'forum_topic', array('nid', 'tid')); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e629cba757
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_delete_file_if_stale/7.x
In Drupal 7, write the function `update_delete_file_if_stale($path)` (file modules/update/update.module) so that it does the following: Deletes stale files and directories from the update manager disk cache.
Files and directories older than 6 hours and development snapshots older than 5 minutes are considered stale. We only cache development snapshots for 5 minutes since otherwise updated snapshots might not be downloaded as expected. When checking file ages, we need to use the ctime, not the mtime (modification time) sin...
function update_delete_file_if_stale($path) { if (file_exists($path)) { $filectime = filectime($path); if (REQUEST_TIME - $filectime > DRUPAL_MAXIMUM_TEMP_FILE_AGE || (preg_match('/.*-dev\.(tar\.gz|zip)/i', $path) && REQUEST_TIME - $filectime > 300)) { file_unmanaged_delete_recursive($path); } } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e62c381220
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin_account_submit/7.x
I need the code for `user_admin_account_submit($form, &$form_state)` in Drupal 7 (modules/user/user.admin.inc). It must do this: Submit the user administration update form.
File: modules/user/user.admin.inc
function user_admin_account_submit($form, &$form_state) { $operations = module_invoke_all('user_operations', $form, $form_state); $operation = $operations[$form_state['values']['operation']]; // Filter out unchecked accounts. $accounts = array_filter($form_state['values']['accounts']); if ($function = $operat...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e6458e14de
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21module.inc/function/module_hook_info/7.x
Implement `module_hook_info()` in PHP for Drupal 7. Required behavior: Retrieves a list of hooks that are declared through hook_hook_info().
Returns: An associative array whose keys are hook names and whose values are an associative array containing a group name. The structure of the array is the same as the return value of hook_hook_info(). File: includes/module.inc
function module_hook_info() { // This function is indirectly invoked from bootstrap_invoke_all(), in which // case common.inc, subsystems, and modules are not loaded yet, so it does not // make sense to support hook groups resp. lazy-loaded include files prior to // full bootstrap. if (drupal_bootstrap(NULL, ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e64cf0a217
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_list/7.x
I need the code for `block_list($region)` in Drupal 7 (modules/block/block.module). It must do this: Returns all blocks in the specified region for the current user.
Parameters: - $region: The name of a region. Returns: An array of block objects, indexed with the module name and block delta concatenated with an underscore, thus: MODULE_DELTA. If you are displaying your blocks in one or two sidebars, you may check whether this array is empty to see how many columns are going to be ...
function block_list($region) { $blocks = &drupal_static(__FUNCTION__); if (!isset($blocks)) { $blocks = _block_load_blocks(); } // Create an empty array if there are no entries. if (!isset($blocks[$region])) { $blocks[$region] = array(); } else { $blocks[$region] = _block_render_blocks($bloc...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e65d3527f0
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_language_alter/7.x
Give me the example code for `hook_field_language_alter(&$display_language, $context)` in Drupal 7. Hook description: Perform alterations on field_language() values.
This hook is invoked to alter the array of display languages for the given entity. Parameters: - $display_language: A reference to an array of language codes keyed by field name. - $context: An associative array containing: - entity_type: The type of the entity to be displayed. - entity: The entity with fields to rend...
function hook_field_language_alter(&$display_language, $context) { // Do not apply core language fallback rules if they are disabled or if Locale // is not registered as a translation handler. if (variable_get('locale_field_language_fallback', TRUE) && field_has_translation_handler($context['entity_type'], 'local...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-e66824442f
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/theme_aggregator_page_opml/7.x
I need the code for `theme_aggregator_page_opml($variables)` in Drupal 7 (modules/aggregator/aggregator.pages.inc). It must do this: Prints the OPML page for the feed.
Parameters: - $variables: An associative array containing: - feeds: An array of the feeds to theme. File: modules/aggregator/aggregator.pages.inc
function theme_aggregator_page_opml($variables) { $feeds = $variables['feeds']; drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8'); $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<opml version=\"1.1\">\n"; $output .= "<head>\n"; $output .= '<title>' . check_plain(var...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e686bb9ce3
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.compare.inc/function/update_filter_project_info/7.x
I need the code for `update_filter_project_info($info)` in Drupal 7 (modules/update/update.compare.inc). It must do this: Filters the project .info data to only save attributes we need.
Parameters: - $info (array): Array of .info file data as returned by drupal_parse_info_file(). Returns (Array): of .info file data we need for the update manager. File: modules/update/update.compare.inc
function update_filter_project_info($info) { $whitelist = array( '_info_file_ctime', 'datestamp', 'major', 'name', 'package', 'project', 'project status url', 'version', ); return array_intersect_key($info, drupal_map_assoc($whitelist)); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e6a11340e2
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_invalidate_js/7.x
Implement `_locale_invalidate_js($langcode = NULL)` in PHP for Drupal 7. Required behavior: Force the JavaScript translation file(s) to be refreshed.
This function sets a refresh flag for a specified language, or all languages except English, if none specified. JavaScript translation files are rebuilt (with locale_update_js_files()) the next time a request is served in that language. Parameters: - $langcode: The language code for which the file needs to be refreshe...
function _locale_invalidate_js($langcode = NULL) { $parsed = variable_get('javascript_parsed', array()); if (empty($langcode)) { // Invalidate all languages. $languages = language_list(); unset($languages['en']); foreach ($languages as $lcode => $data) { $parsed['refresh:' . $lcode] = 'waitin...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e6bd7e6029
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_clear_js_cache/7.x
In Drupal 7, write the function `drupal_clear_js_cache()` (file includes/common.inc) so that it does the following: Deletes old cached JavaScript files and variables.
File: includes/common.inc
function drupal_clear_js_cache() { variable_del('javascript_parsed'); variable_del('drupal_js_cache_files'); file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale')); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e6bf7d5acb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_node_delete/7.x
Implement `translation_node_delete($node)` in PHP for Drupal 7. Required behavior: Implements hook_node_delete().
File: modules/translation/translation.module
function translation_node_delete($node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { translation_remove_from_set($node); } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e6d5b5734d
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/variable_del/7.x
Implement `variable_del($name)` in PHP for Drupal 7. Required behavior: Unsets a persistent variable.
Case-sensitivity of the variable_* functions depends on the database collation used. To avoid problems, always use lower case for persistent variable names. Parameters: - $name: The name of the variable to undefine. File: includes/bootstrap.inc
function variable_del($name) { global $conf; db_delete('variable') ->condition('name', $name) ->execute(); cache_clear_all('variables', 'cache_bootstrap'); unset($conf[$name]); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e6e74eac75
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21search%21search.install/function/search_uninstall/7.x
I need the code for `search_uninstall()` in Drupal 7 (modules/search/search.install). It must do this: Implements hook_uninstall().
File: modules/search/search.install
function search_uninstall() { variable_del('minimum_word_size'); variable_del('overlap_cjk'); variable_del('search_cron_limit'); variable_del('search_logging'); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e71ba689de
7
drupal_api_code
https://api.drupal.org/api/drupal/update.php/function/update_task_list/7.x
In Drupal 7, write the function `update_task_list($active = NULL)` (file update.php) so that it does the following: Adds the update task list to the current page.
File: update.php
function update_task_list($active = NULL) { // Default list of tasks. $tasks = array( 'requirements' => 'Verify requirements', 'info' => 'Overview', 'select' => 'Review updates', 'run' => 'Run updates', 'finished' => 'Review log', ); drupal_add_region_content('sidebar_first', theme('task_li...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e725aa087b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_view_alter/7.x
In Drupal 7, show an example implementation for `hook_user_view_alter(&$build)` (modules/user/user.api.php): The user was built; the module may modify the structured content.
This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete user content structure has been built. If the module wishes to act on the rendered HTML of the user rather than the structured content array, it may use this hook to add ...
function hook_user_view_alter(&$build) { // Check for the existence of a field added by another module. if (isset($build['an_additional_field'])) { // Change its weight. $build['an_additional_field']['#weight'] = -10; } // Add a #post_render callback to act on the rendered HTML of the user. $build['#...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-e72d30fcf7
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_rdfa_attributes/7.x
I need the code for `rdf_rdfa_attributes($mapping, $data = NULL)` in Drupal 7 (modules/rdf/rdf.module). It must do this: Builds an array of RDFa attributes for a given mapping. This array will typically be passed through drupal_attributes() to create the attributes variables that are available to template files. These ...
Parameters: - $mapping: An array containing a mandatory 'predicates' key and optional 'datatype', 'callback' and 'type' keys. For example: @code array( 'predicates' => array('dc:created'), 'datatype' => 'xsd:dateTime', 'callback' => 'date_iso8601', ), ); @endcode - $data: A value that needs to be converted by the provi...
function rdf_rdfa_attributes($mapping, $data = NULL) { // The type of mapping defaults to 'property'. $type = isset($mapping['type']) ? $mapping['type'] : 'property'; switch ($type) { // The mapping expresses the relationship between two resources. case 'rel': case 'rev': $attributes[$type] = $...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e7715d5ec4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_load/7.x
I need the code for `poll_load($nodes)` in Drupal 7 (modules/poll/poll.module). It must do this: Implements hook_load().
File: modules/poll/poll.module
function poll_load($nodes) { global $user; foreach ($nodes as $node) { $poll = db_query("SELECT runtime, active FROM {poll} WHERE nid = :nid", array(':nid' => $node->nid))->fetchObject(); if (empty($poll)) { $poll = new stdClass(); } // Load the appropriate choices into the $poll object. ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e771c46b10
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_node_view/7.x
In Drupal 7, write the function `forum_node_view($node, $view_mode)` (file modules/forum/forum.module) so that it does the following: Implements hook_node_view().
File: modules/forum/forum.module
function forum_node_view($node, $view_mode) { if (!empty($node->forum_tid) && _forum_node_check_node_type($node)) { if ($view_mode == 'full' && node_is_page($node)) { $vid = variable_get('forum_nav_vocabulary', 0); $vocabulary = taxonomy_vocabulary_load($vid); // Breadcrumb navigation $bre...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e7742fc69b
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/drupal_prepare_form/7.x
Implement `drupal_prepare_form($form_id, &$form, &$form_state)` in PHP for Drupal 7. Required behavior: Prepares a structured form array.
Adds required elements, executes any hook_form_alter functions, and optionally inserts a validation token to prevent tampering. Parameters: - $form_id: A unique string identifying the form for validation, submission, theming, and hook_form_alter functions. - $form: An associative array containing the structure of the ...
function drupal_prepare_form($form_id, &$form, &$form_state) { global $user; $form['#type'] = 'form'; $form_state['programmed'] = isset($form_state['programmed']) ? $form_state['programmed'] : FALSE; // Fix the form method, if it is 'get' in $form_state, but not in $form. if ($form_state['method'] == 'get' ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e7b76dc361
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21theme.api.php/function/hook_form_system_theme_settings_alter/7.x
Give me the example code for `hook_form_system_theme_settings_alter(&$form, &$form_state)` in Drupal 7. Hook description: Allow themes to alter the theme-specific settings form.
With this hook, themes can alter the theme-specific settings form in any way allowable by Drupal's Form API, such as adding form elements, changing default values and removing form elements. See the Form API documentation on api.drupal.org for detailed information. Note that the base theme's form alterations will be r...
function hook_form_system_theme_settings_alter(&$form, &$form_state) { // Add a checkbox to toggle the breadcrumb trail. $form['toggle_breadcrumb'] = array( '#type' => 'checkbox', '#title' => t('Display the breadcrumb'), '#default_value' => theme_get_setting('toggle_breadcrumb'), '#description' =>...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-e7dbcedf44
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_delete_menu_page/7.x
I need the code for `menu_delete_menu_page($menu)` in Drupal 7 (modules/menu/menu.admin.inc). It must do this: Menu callback; check access and get a confirm form for deletion of a custom menu.
File: modules/menu/menu.admin.inc
function menu_delete_menu_page($menu) { // System-defined menus may not be deleted. $system_menus = menu_list_system_menus(); if (isset($system_menus[$menu['menu_name']])) { return MENU_ACCESS_DENIED; } return drupal_get_form('menu_delete_menu_confirm', $menu); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e7ed59a2a4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.module/function/simpletest_last_test_get/7.x
Implement `simpletest_last_test_get($test_id)` in PHP for Drupal 7. Required behavior: Get information about the last test that ran given a test ID.
Parameters: - $test_id: The test ID to get the last test from. Returns (Array): containing the last database prefix used and the last test class that ran. File: modules/simpletest/simpletest.module
function simpletest_last_test_get($test_id) { $last_prefix = db_query_range('SELECT last_prefix FROM {simpletest_test_id} WHERE test_id = :test_id', 0, 1, array(':test_id' => $test_id))->fetchField(); $last_test_class = db_query_range('SELECT test_class FROM {simpletest} WHERE test_id = :test_id ORDER BY message_id...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e7fccb7132
7
drupal_api_code
https://api.drupal.org/api/drupal/themes%21garland%21template.php/function/garland_process_page/7.x
Implement `garland_process_page(&$variables)` in PHP for Drupal 7. Required behavior: Override or insert variables into the page template.
File: themes/garland/template.php
function garland_process_page(&$variables) { // Hook into color.module if (module_exists('color')) { _color_page_alter($variables); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8099c23ae
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21syslog%21syslog.module/function/syslog_help/7.x
I need the code for `syslog_help($path, $arg)` in Drupal 7 (modules/syslog/syslog.module). It must do this: Implements hook_help().
File: modules/syslog/syslog.module
function syslog_help($path, $arg) { switch ($path) { case 'admin/help#syslog': $output = ''; $output .= '<h3>' . t('About') . '</h3>'; $output .= '<p>' . t("The Syslog module logs events by sending messages to the logging facility of your web server's operating system. Syslog is an operating sys...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e8195f0c58
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.admin.inc/function/filter_admin_format_page/7.x
In Drupal 7, write the function `filter_admin_format_page($format = NULL)` (file modules/filter/filter.admin.inc) so that it does the following: Page callback: Displays the text format add/edit form.
Parameters: - $format (object|null): (optional) An object representing a format, with the following properties: - format: A machine-readable name representing the ID of the text format to save. If this corresponds to an existing text format, that format will be updated; otherwise, a new format will be created. - name: ...
function filter_admin_format_page($format = NULL) { if (!isset($format->name)) { drupal_set_title(t('Add text format')); $format = (object) array( 'format' => NULL, 'name' => '', ); } return drupal_get_form('filter_admin_format_form', $format); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e81fa73c93
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/image_field_widget_info/7.x
I need the code for `image_field_widget_info()` in Drupal 7 (modules/image/image.field.inc). It must do this: Implements hook_field_widget_info().
File: modules/image/image.field.inc
function image_field_widget_info() { return array( 'image_image' => array( 'label' => t('Image'), 'field types' => array('image'), 'settings' => array( 'progress_indicator' => 'throbber', 'preview_image_style' => 'thumbnail', ), 'behaviors' => array( 'multiple...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e828a41d22
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21block%21block.admin.inc/function/_block_compare/7.x
I need the code for `_block_compare($a, $b)` in Drupal 7 (modules/block/block.admin.inc). It must do this: Sorts active blocks by region, then by weight; sorts inactive blocks by name.
Callback for usort() in block_admin_display_prepare_blocks(). File: modules/block/block.admin.inc
function _block_compare($a, $b) { global $theme_key; // Theme should be set before calling this function, or the current theme // is being used. $theme = &drupal_static(__FUNCTION__ . ':theme'); if (!isset($theme)) { $theme = $theme_key; } $regions = &drupal_static(__FUNCTION__ . ':regions'); // W...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e82ac46c32
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_box_form_submit/7.x
I need the code for `search_box_form_submit($form, &$form_state)` in Drupal 7 (modules/search/search.module). It must do this: Process a block search form submission.
File: modules/search/search.module
function search_box_form_submit($form, &$form_state) { // The search form relies on control of the redirect destination for its // functionality, so we override any static destination set in the request, // for example by drupal_access_denied() or drupal_not_found() // (see http://drupal.org/node/292565). if ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e832dcb133
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_style_form_add_submit/7.x
Implement `image_style_form_add_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit handler for adding a new image effect to an image style.
File: modules/image/image.admin.inc
function image_style_form_add_submit($form, &$form_state) { $style = $form_state['image_style']; // Check if this field has any configuration options. $effect = image_effect_definition_load($form_state['values']['new']); // Load the configuration form for this option. if (isset($effect['form callback'])) { ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e83afe9ac5
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7060/7.x
Implement `system_update_7060()` in PHP for Drupal 7. Required behavior: Create fields in preparation for migrating upload.module to file.module.
File: modules/system/system.install
function system_update_7060() { if (!db_table_exists('upload')) { return; } if (!db_query_range('SELECT 1 FROM {upload}', 0, 1)->fetchField()) { // There is nothing to migrate. Delete variables and the empty table. There // is no need to create fields that are not going to be used. foreach (_upda...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8863048ec
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_help/7.x
In Drupal 7, write the function `toolbar_help($path, $arg)` (file modules/toolbar/toolbar.module) so that it does the following: Implements hook_help().
File: modules/toolbar/toolbar.module
function toolbar_help($path, $arg) { switch ($path) { case 'admin/help#toolbar': $output = '<h3>' . t('About') . '</h3>'; $output .= '<p>' . t('The Toolbar module displays links to top-level administration menu items and links from other modules at the top of the screen. For more information, see the ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e88e6611d2
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_import_shorten_comments/7.x
In Drupal 7, write the function `_locale_import_shorten_comments($comment)` (file includes/locale.inc) so that it does the following: Generate a short, one string version of the passed comment array
Parameters: - $comment: An array of strings containing a comment. Returns: Short one string version of the comment. File: includes/locale.inc
function _locale_import_shorten_comments($comment) { $comm = ''; while (count($comment)) { $test = $comm . substr(array_shift($comment), 1) . ', '; if (strlen($comm) < 130) { $comm = $test; } else { break; } } return trim(substr($comm, 0, -2)); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8abb7fad5
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_breadcrumb/7.x
I need the code for `theme_breadcrumb($variables)` in Drupal 7 (includes/theme.inc). It must do this: Returns HTML for a breadcrumb trail.
Parameters: - $variables: An associative array containing: - breadcrumb: An array containing the breadcrumb links. File: includes/theme.inc
function theme_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; if (!empty($breadcrumb)) { // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. Make the heading invisible with .element-invisible. $output = '<h2 class="element-invisible">' . t...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8aff8c8e7
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_refresh/7.x
I need the code for `update_refresh()` in Drupal 7 (modules/update/update.module). It must do this: Refreshes the release data after loading the necessary include file.
File: modules/update/update.module
function update_refresh() { module_load_include('inc', 'update', 'update.fetch'); return _update_refresh(); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8cb1c5555
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21session.inc/function/drupal_session_commit/7.x
In Drupal 7, write the function `drupal_session_commit()` (file includes/session.inc) so that it does the following: Commits the current session, if necessary.
If an anonymous user already have an empty session, destroy it. File: includes/session.inc
function drupal_session_commit() { global $user, $is_https; if (!drupal_save_session()) { // We don't have anything to do if we are not allowed to save the session. return; } if (empty($user->uid) && empty($_SESSION)) { // There is no session data to store, destroy the session if it was // pre...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8e2f5cd15
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_unmanaged_move/7.x
In Drupal 7, write the function `file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME)` (file includes/file.inc) so that it does the following: Moves a file to a new location without database changes or hook invocation.
Parameters: - $source: A string specifying the filepath or URI of the original file. - $destination: A string containing the destination that $source should be moved to. This must be a stream wrapper URI. If this value is omitted, Drupal's default files scheme will be used, usually "public://". - $replace: Replace beha...
function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) { $filepath = file_unmanaged_copy($source, $destination, $replace); if ($filepath == FALSE || file_unmanaged_delete($source) == FALSE) { return FALSE; } return $filepath; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8e47d479e
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/valid_email_address/7.x
I need the code for `valid_email_address($mail)` in Drupal 7 (includes/common.inc). It must do this: Verifies the syntax of the given e-mail address.
This uses the Parameters: - $mail: A string containing an e-mail address. Returns: TRUE if the address is in a valid format. File: includes/common.inc
function valid_email_address($mail) { $valid = (bool) filter_var($mail, FILTER_VALIDATE_EMAIL); drupal_alter('valid_email_address', $valid, $mail); return $valid; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e8f68a0352
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.api.php/function/hook_update_status_alter/7.x
Give me the example code for `hook_update_status_alter(&$projects)` in Drupal 7. Hook description: Alter the information about available updates for projects.
Parameters: - $projects: Reference to an array of information about available updates to each project installed on the system. File: modules/update/update.api.php
function hook_update_status_alter(&$projects) { $settings = variable_get('update_advanced_project_settings', array()); foreach ($projects as $project => $project_info) { if (isset($settings[$project]) && isset($settings[$project]['check']) && ($settings[$project]['check'] == 'never' || (isset(...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-e9348567f0
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_unmanaged_delete/7.x
In Drupal 7, write the function `file_unmanaged_delete($path)` (file includes/file.inc) so that it does the following: Deletes a file without database changes or hook invocations.
This function should be used when the file to be deleted does not have an entry recorded in the files table. Parameters: - $path: A string containing a file path or (streamwrapper) URI. Returns: TRUE for success or path does not exist, or FALSE in the event of an error. File: includes/file.inc
function file_unmanaged_delete($path) { if (is_dir($path)) { watchdog('file', '%path is a directory and cannot be removed using file_unmanaged_delete().', array('%path' => $path), WATCHDOG_ERROR); return FALSE; } if (is_file($path)) { return drupal_unlink($path); } // Return TRUE for non-existent ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e94cf22b56
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_allowed_values_setting_validate/7.x
Implement `list_allowed_values_setting_validate($element, &$form_state)` in PHP for Drupal 7. Required behavior: Element validate callback; check that the entered values are valid.
File: modules/field/modules/list/list.module
function list_allowed_values_setting_validate($element, &$form_state) { $field = $element['#field']; $has_data = $element['#field_has_data']; $field_type = $field['type']; $generate_keys = ($field_type == 'list_integer' || $field_type == 'list_float') && !$has_data; $values = list_extract_allowed_values($ele...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9518fff95
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_login_submit/7.x
In Drupal 7, write the function `user_login_submit($form, &$form_state)` (file modules/user/user.module) so that it does the following: Submit handler for the login form. Load $user object and perform standard login tasks. The user is then redirected to the My Account page. Setting the destination in the query string o...
File: modules/user/user.module
function user_login_submit($form, &$form_state) { global $user; $user = user_load($form_state['uid']); $form_state['redirect'] = 'user/' . $user->uid; user_login_finalize($form_state); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9650a100e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_get_file_references/7.x
I need the code for `file_get_file_references($file, $field = NULL, $age = FIELD_LOAD_REVISION, $field_type = 'file', $check_access = TRUE)` in Drupal 7 (modules/file/file.module). It must do this: Retrieves a list of references to a file.
Parameters: - $file: A file object. - $field: (optional) A field array to be used for this check. If given, limits the reference check to the given field. - $age: (optional) A constant that specifies which references to count. Use FIELD_LOAD_REVISION to retrieve all references within all revisions or FIELD_LOAD_CURRENT...
function file_get_file_references($file, $field = NULL, $age = FIELD_LOAD_REVISION, $field_type = 'file', $check_access = TRUE) { $references = drupal_static(__FUNCTION__, array()); $fields = isset($field) ? array($field['field_name'] => $field) : field_info_fields(); foreach ($fields as $field_name => $file_fie...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e96a9d890e
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_http_header_attributes/7.x
In Drupal 7, write the function `drupal_http_header_attributes(array $attributes = array())` (file includes/common.inc) so that it does the following: Formats an attribute string for an HTTP header.
Parameters: - $attributes: An associative array of attributes such as 'rel'. Returns: A ; separated string ready for insertion in a HTTP header. No escaping is performed for HTML entities, so this string is not safe to be printed. File: includes/common.inc
function drupal_http_header_attributes(array $attributes = array()) { foreach ($attributes as $attribute => &$data) { if (is_array($data)) { $data = implode(' ', $data); } $data = $attribute . '="' . $data . '"'; } return $attributes ? ' ' . implode('; ', $attributes) : ''; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9a51e285b
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_active_breadcrumb/7.x
Implement `menu_get_active_breadcrumb()` in PHP for Drupal 7. Required behavior: Gets the breadcrumb for the current page, as determined by the active trail.
File: includes/menu.inc
function menu_get_active_breadcrumb() { $breadcrumb = array(); // No breadcrumb for the front page. if (drupal_is_front_page()) { return $breadcrumb; } $item = menu_get_item(); if (!empty($item['access'])) { $active_trail = menu_get_active_trail(); // Allow modules to alter the breadcrumb, if...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9aef457b5
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21errors.inc/function/_drupal_log_error/7.x
Implement `_drupal_log_error($error, $fatal = FALSE)` in PHP for Drupal 7. Required behavior: Logs a PHP error or exception and displays an error page in fatal cases.
Parameters: - $error: An array with the following keys: %type, !message, %function, %file, %line and severity_level. All the parameters are plain-text, with the exception of !message, which needs to be a safe HTML string. - $fatal: TRUE if the error is fatal. File: includes/errors.inc
function _drupal_log_error($error, $fatal = FALSE) { // Initialize a maintenance theme if the bootstrap was not complete. // Do it early because drupal_set_message() triggers a drupal_theme_initialize(). if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) { unset($GLOBALS['theme']); if ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9c4207f16
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/form_type_textarea_value/7.x
I need the code for `form_type_textarea_value($element, $input = FALSE)` in Drupal 7 (includes/form.inc). It must do this: Determines the value for a textarea form element.
Parameters: - $element (array): The form element whose value is being populated. - $input (mixed): The incoming input to populate the form element. If this is FALSE, the element's default value should be returned. Returns (string): The data that will appear in $form_state['values'] for this element, or nothing to use ...
function form_type_textarea_value($element, $input = FALSE) { if ($input !== FALSE && $input !== NULL) { // This should be a string, but allow other scalars since they might be // valid input in programmatic form submissions. return is_scalar($input) ? (string) $input : ''; } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9d6f7e237
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_theme/7.x
In Drupal 7, write the function `node_theme()` (file modules/node/node.module) so that it does the following: Implements hook_theme().
File: modules/node/node.module
function node_theme() { return array( 'node' => array( 'render element' => 'elements', 'template' => 'node', ), 'node_search_admin' => array( 'render element' => 'form', ), 'node_add_list' => array( 'variables' => array('content' => NULL), 'file' => 'node.pages.inc', ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-e9eb714d2a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_storage_info/7.x
Give me the example code for `hook_field_storage_info()` in Drupal 7. Hook description: Expose Field API storage backends.
Returns: An array describing the storage backends implemented by the module. The keys are storage backend names. To avoid name clashes, storage backend names should be prefixed with the name of the module that exposes them. The values are arrays describing the storage backend, with the following key/value pairs: - labe...
function hook_field_storage_info() { return array( 'field_sql_storage' => array( 'label' => t('Default SQL storage'), 'description' => t('Stores fields in the local SQL database, using per-field tables.'), 'settings' => array(), ), ); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-e9f1bd3df6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.pages.inc/function/simpletest_result_form_submit/7.x
Implement `simpletest_result_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Re-run the tests that match the filter.
File: modules/simpletest/simpletest.pages.inc
function simpletest_result_form_submit($form, &$form_state) { $pass = $form_state['values']['filter_pass'] ? explode(',', $form_state['values']['filter_pass']) : array(); $fail = $form_state['values']['filter_fail'] ? explode(',', $form_state['values']['filter_fail']) : array(); if ($form_state['values']['filter...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9f65c882b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.install/function/comment_update_7006/7.x
In Drupal 7, write the function `comment_update_7006(&$sandbox)` (file modules/comment/comment.install) so that it does the following: Migrate data from the comment field to field storage.
File: modules/comment/comment.install
function comment_update_7006(&$sandbox) { // This is a multipass update. First set up some comment variables. if (empty($sandbox['total'])) { $comments = (bool) db_query_range('SELECT 1 FROM {comment}', 0, 1)->fetchField(); $sandbox['types'] = array(); if ($comments) { $sandbox['types'] = array_ke...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-e9f74fde7f
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_pick_book_nojs_submit/7.x
I need the code for `book_pick_book_nojs_submit($form, &$form_state)` in Drupal 7 (modules/book/book.module). It must do this: Form submission handler for node_form().
This handler is run when JavaScript is disabled. It triggers the form to rebuild so that the "Parent item" options are changed to reflect the newly selected book. When JavaScript is enabled, the submit button that triggers this handler is hidden, and the "Book" dropdown directly triggers the book_form_update() Ajax cal...
function book_pick_book_nojs_submit($form, &$form_state) { $form_state['node']->book = $form_state['values']['book']; $form_state['rebuild'] = TRUE; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea04688fec
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/theme_field_ui_table/7.x
In Drupal 7, write the function `theme_field_ui_table($variables)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Returns HTML for Field UI overview tables.
Parameters: - $variables: An associative array containing: - elements: An associative array containing a Form API structure to be rendered as a table. File: modules/field_ui/field_ui.admin.inc
function theme_field_ui_table($variables) { $elements = $variables['elements']; $table = array(); $js_settings = array(); // Add table headers and attributes. foreach (array('header', 'attributes') as $key) { if (isset($elements["#$key"])) { $table[$key] = $elements["#$key"]; } } // Determ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea2038105d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.pages.inc/function/simpletest_settings_form/7.x
I need the code for `simpletest_settings_form($form, &$form_state)` in Drupal 7 (modules/simpletest/simpletest.pages.inc). It must do this: Provides settings form for SimpleTest variables.
File: modules/simpletest/simpletest.pages.inc
function simpletest_settings_form($form, &$form_state) { $form['general'] = array( '#type' => 'fieldset', '#title' => t('General'), ); $form['general']['simpletest_clear_results'] = array( '#type' => 'checkbox', '#title' => t('Clear results after each complete test suite run'), '#description' ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea30426bdf
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_theme_initialize/7.x
I need the code for `block_theme_initialize($theme)` in Drupal 7 (modules/block/block.module). It must do this: Assigns an initial, default set of blocks for a theme.
This function is called the first time a new theme is enabled. The new theme gets a copy of the default theme's blocks, with the difference that if a particular region isn't available in the new theme, the block is assigned to the new theme's default region. Parameters: - $theme: The name of a theme. File: modules/bl...
function block_theme_initialize($theme) { // Initialize theme's blocks if none already registered. $has_blocks = (bool) db_query_range('SELECT 1 FROM {block} WHERE theme = :theme', 0, 1, array(':theme' => $theme))->fetchField(); if (!$has_blocks) { $default_theme = variable_get('theme_default', 'bartik'); ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea30c4dd16
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.install/function/node_update_7008/7.x
Implement `node_update_7008()` in PHP for Drupal 7. Required behavior: Split the 'administer nodes' permission from 'access content overview'.
File: modules/node/node.install
function node_update_7008() { $roles = user_roles(FALSE, 'administer nodes'); foreach ($roles as $rid => $role) { _update_7000_user_role_grant_permissions($rid, array('access content overview'), 'node'); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea4b40a2c2
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/request_path/7.x
Implement `request_path()` in PHP for Drupal 7. Required behavior: Returns the requested URL path of the page being viewed.
Examples: - http://example.com/node/306 returns "node/306". - http://example.com/drupalfolder/node/306 returns "node/306" while base_path() returns "/drupalfolder/". - http://example.com/path/alias (which is a path alias for node/306) returns "path/alias" as opposed to the internal path. - http://example.com/index....
function request_path() { static $path; if (isset($path)) { return $path; } if (isset($_GET['q']) && is_string($_GET['q'])) { // This is a request with a ?q=foo/bar query string. $_GET['q'] is // overwritten in drupal_path_initialize(), but request_path() is called // very early in the bootstr...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea59247fc0
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_page_footer/7.x
Implement `drupal_page_footer()` in PHP for Drupal 7. Required behavior: Performs end-of-request tasks.
This function sets the page cache if appropriate, and allows modules to react to the closing of the page by calling hook_exit(). File: includes/common.inc
function drupal_page_footer() { global $user; module_invoke_all('exit'); // Commit the user session, if needed. drupal_session_commit(); if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) { drupal_serve_page_from_cache($cache); } else { ob_flush(); } _registry_check_code(R...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea6e511e27
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_menu/7.x
Implement `dashboard_menu()` in PHP for Drupal 7. Required behavior: Implements hook_menu().
File: modules/dashboard/dashboard.module
function dashboard_menu() { $items['admin/dashboard'] = array( 'title' => 'Dashboard', 'description' => 'View and customize your dashboard.', 'page callback' => 'dashboard_admin', 'access arguments' => array('access dashboard'), // Make this appear first, so for example, in admin menus, it shows u...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ea769344ea
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_no_profile_error/7.x
I need the code for `install_no_profile_error()` in Drupal 7 (includes/install.core.inc). It must do this: Indicates that there are no profiles available.
File: includes/install.core.inc
function install_no_profile_error() { drupal_set_title(st('No profiles available')); return st('We were unable to find any installation profiles. Installation profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.'); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea7e55370c
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_link_load/7.x
Implement `menu_link_load($mlid)` in PHP for Drupal 7. Required behavior: Gets a translated, access-checked menu link that is ready for rendering.
This function should never be called from within node_load() or any other function used as a menu object load function since an infinite recursion may occur. Parameters: - $mlid: The mlid of the menu item. Returns: A menu link, with $item['access'] filled and link translated for rendering. File: includes/menu.inc
function menu_link_load($mlid) { if (is_numeric($mlid)) { $query = db_select('menu_links', 'ml'); $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path'); $query->fields('ml'); // Weight should be taken from {menu_links}, not {menu_router}. $query->addField('ml', 'weight', 'link_weight'); ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ea97860173
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_field_prepare_translation/7.x
Implement `text_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)` in PHP for Drupal 7. Required behavior: Implements hook_field_prepare_translation().
File: modules/field/modules/text/text.module
function text_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) { // If the translating user is not permitted to use the assigned text format, // we must not expose the source values. $field_name = $field['field_name']; if (!empty($source_e...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ea9a00efab
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/callback_entity_info_uri/7.x
Give me the example code for `callback_entity_info_uri($entity)` in Drupal 7. Hook description: Return the URI for an entity.
Callback for hook_entity_info(). Parameters: - $entity: The entity to return the URI for. Returns: An associative array with the following elements: - 'path': The URL path for the entity. - 'options': (optional) An array of options for the url() function. The actual entity URI can be constructed by passing these elem...
function callback_entity_info_uri($entity) { return array( 'path' => 'node/' . $entity->nid, ); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-eaa791c489
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_form_dashboard_admin_display_form_alter/7.x
In Drupal 7, write the function `dashboard_form_dashboard_admin_display_form_alter(&$form, &$form_state)` (file modules/dashboard/dashboard.module) so that it does the following: Implements hook_form_FORM_ID_alter().
File: modules/dashboard/dashboard.module
function dashboard_form_dashboard_admin_display_form_alter(&$form, &$form_state) { // Redirect the 'configure' and 'delete' links on each block back to the // dashboard blocks administration page. foreach ($form['blocks'] as &$block) { if (isset($block['configure']['#href'])) { $block['configure']['#opt...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-eaaf9ccc39
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.module/function/simpletest_clean_database/7.x
In Drupal 7, write the function `simpletest_clean_database()` (file modules/simpletest/simpletest.module) so that it does the following: Removed prefixed tables from the database that are left over from crashed tests.
File: modules/simpletest/simpletest.module
function simpletest_clean_database() { $tables = db_find_tables_d8(Database::getConnection()->prefixTables('{simpletest}') . '%'); $schema = drupal_get_schema_unprocessed('simpletest'); $count = 0; foreach (array_diff_key($tables, $schema) as $table) { // Strip the prefix and skip tables without digits foll...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-eabdf23817
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_get_math_library/7.x
I need the code for `_openid_get_math_library()` in Drupal 7 (modules/openid/openid.inc). It must do this: Determine the available math library GMP vs. BCMath, favouring GMP for performance.
File: modules/openid/openid.inc
function _openid_get_math_library() { // Not drupal_static(), because a function is not going to disappear and // change the output of this under any circumstances. static $library; if (empty($library)) { if (function_exists('gmp_add')) { $library = 'gmp'; } elseif (function_exists('bcadd'))...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-eacdff60ac
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/statistics_exit/7.x
In Drupal 7, write the function `statistics_exit()` (file modules/statistics/statistics.module) so that it does the following: Implements hook_exit().
Gathers statistics for page accesses. File: modules/statistics/statistics.module
function statistics_exit() { global $user; // When serving cached pages with the 'page_cache_without_database' // configuration, system variables need to be loaded. This is a major // performance decrease for non-database page caches, but with Statistics // module, it is likely to also have 'statistics_enabl...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-eadd6b1e13
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21book%21book.admin.inc/function/book_admin_settings/7.x
Implement `book_admin_settings()` in PHP for Drupal 7. Required behavior: Form constructor for the book settings form.
File: modules/book/book.admin.inc
function book_admin_settings() { $types = node_type_get_names(); $form['book_allowed_types'] = array( '#type' => 'checkboxes', '#title' => t('Content types allowed in book outlines'), '#default_value' => variable_get('book_allowed_types', array('book')), '#options' => $types, '#description' => t...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-eaf53ee58e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/theme_comment_block/7.x
I need the code for `theme_comment_block()` in Drupal 7 (modules/comment/comment.module). It must do this: Returns HTML for a list of recent comments to be displayed in the comment block.
File: modules/comment/comment.module
function theme_comment_block() { $items = array(); $number = variable_get('comment_block_count', 10); foreach (comment_get_recent($number) as $comment) { $items[] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . '&nbsp;<span>' . t('@time ago', array('@time'...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-eb213bdf68
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_page_alter/7.x
In Drupal 7, write the function `system_page_alter(&$page)` (file modules/system/system.module) so that it does the following: Implements hook_page_alter().
File: modules/system/system.module
function system_page_alter(&$page) { // Find all non-empty page regions, and add a theme wrapper function that // allows them to be consistently themed. foreach (system_region_list($GLOBALS['theme'], REGIONS_ALL, FALSE) as $region) { if (!empty($page[$region])) { $page[$region]['#theme_wrappers'][] = 'r...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-eb3c13dd98
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_send_email_action_validate/7.x
In Drupal 7, write the function `system_send_email_action_validate($form, $form_state)` (file modules/system/system.module) so that it does the following: Validate system_send_email_action form submissions.
File: modules/system/system.module
function system_send_email_action_validate($form, $form_state) { $form_values = $form_state['values']; // Validate the configuration form. if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) { // We want the literal %author placeholder to be emphasized ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-eb61d9482f
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.admin.inc/function/aggregator_admin_refresh_feed/7.x
In Drupal 7, write the function `aggregator_admin_refresh_feed($feed)` (file modules/aggregator/aggregator.admin.inc) so that it does the following: Page callback: Refreshes a feed, then redirects to the overview page.
Parameters: - $feed: An object describing the feed to be refreshed. File: modules/aggregator/aggregator.admin.inc
function aggregator_admin_refresh_feed($feed) { if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'aggregator/update/' . $feed->fid)) { return MENU_ACCESS_DENIED; } aggregator_refresh($feed); drupal_goto('admin/config/services/aggregator'); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-eb8700901d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_page/7.x
In Drupal 7, write the function `user_page()` (file modules/user/user.pages.inc) so that it does the following: Page callback: Displays the user page.
Displays user profile if user is logged in, or login form for anonymous users. Returns: A render array for either a user profile or a login form. File: modules/user/user.pages.inc
function user_page() { global $user; if ($user->uid) { menu_set_active_item('user/' . $user->uid); return menu_execute_active_handler(NULL, FALSE); } else { return drupal_get_form('user_login'); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-eb9b780ae6
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_tabledrag/7.x
Implement `drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0)` in PHP for Drupal 7. Required behavior: Assists in adding the tableDrag JavaScript behavior to a themed table.
Draggable tables should be used wherever an outline or list of sortable items needs to be arranged by an end-user. Draggable tables are very flexible and can manipulate the value of form elements placed within individual columns. To set up a table to use drag and drop in place of weight select-lists or in place of a f...
function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0) { $js_added = &drupal_static(__FUNCTION__, FALSE); if (!$js_added) { // Add the table drag JavaScript to the page before the module JavaScript // to ensure that table drag b...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ebaa4ad18b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/field_sql_storage_field_storage_write/7.x
Implement `field_sql_storage_field_storage_write($entity_type, $entity, $op, $fields)` in PHP for Drupal 7. Required behavior: Implements hook_field_storage_write().
File: modules/field/modules/field_sql_storage/field_sql_storage.module
function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fields) { list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); if (!isset($vid)) { $vid = $id; } // Check if the given entity is a new revision or not. In case of a new // revision creation, we cannot skip any fi...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ebb7d6b8db
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_set_mode/7.x
I need the code for `overlay_set_mode($mode = NULL)` in Drupal 7 (modules/overlay/overlay.module). It must do this: Sets the overlay mode and adds proper JavaScript and styles to the page.
Note that since setting the overlay mode triggers a variety of behaviors (including hooks being invoked), it can only be done once per page request. Therefore, the first call to this function which passes along a value of the $mode parameter controls the overlay mode that will be used. Parameters: - $mode: To set the ...
function overlay_set_mode($mode = NULL) { global $base_path; $overlay_mode = &drupal_static(__FUNCTION__); // Make sure external resources are not included more than once. Also return // the current mode, if no mode was specified. if (isset($overlay_mode) || !isset($mode)) { return $overlay_mode; } $...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ebe5be40eb
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_chmod/7.x
Implement `drupal_chmod($uri, $mode = NULL)` in PHP for Drupal 7. Required behavior: Sets the permissions on a file or directory.
This function will use the 'file_chmod_directory' and 'file_chmod_file' variables for the default modes for directories and uploaded/generated files. By default these will give everyone read access so that users accessing the files with a user account without the webserver group (e.g. via FTP) can read these files, and...
function drupal_chmod($uri, $mode = NULL) { if (!isset($mode)) { if (is_dir($uri)) { $mode = variable_get('file_chmod_directory', 0775); } else { $mode = variable_get('file_chmod_file', 0664); } } // If this URI is a stream, pass it off to the appropriate stream wrapper. // Otherwis...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ebf1256881
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21language.inc/function/language_negotiation_set/7.x
Implement `language_negotiation_set($type, $language_providers)` in PHP for Drupal 7. Required behavior: Saves a list of language negotiation providers.
Parameters: - $type: The language negotiation type. - $language_providers: An array of language negotiation provider weights keyed by provider ID. @see language_provider_weight() File: includes/language.inc
function language_negotiation_set($type, $language_providers) { // Save only the necessary fields. $provider_fields = array('callbacks', 'file', 'cache'); $negotiation = array(); $providers_weight = array(); $defined_providers = language_negotiation_info(); $default_types = language_types_configurable(FALS...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ec18330bc4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.api.php/function/hook_image_style_flush/7.x
Give me the example code for `hook_image_style_flush($style)` in Drupal 7. Hook description: Respond to image style flushing.
This hook enables modules to take effect when a style is being flushed (all images are being deleted from the server and regenerated). Any module-specific caches that contain information related to the style should be cleared using this hook. This hook is called whenever a style is updated, deleted, or any effect assoc...
function hook_image_style_flush($style) { // Empty cached data that contains information about the style. cache_clear_all('*', 'cache_mymodule', TRUE); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-ec1e128b69
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.form.inc/function/field_widget_instance/7.x
Implement `field_widget_instance($element, $form_state)` in PHP for Drupal 7. Required behavior: Retrieves the instance definition array for a widget's helper callbacks.
Widgets helper element callbacks (such as #process, #element_validate, #value_callback, ...) should use field_widget_field() and field_widget_instance() instead of field_info_field() and field_info_instance() when they need to access field or instance properties. See hook_field_widget_form() for more details. Paramete...
function field_widget_instance($element, $form_state) { $field_state = field_form_get_state($element['#field_parents'], $element['#field_name'], $element['#language'], $form_state); return $field_state['instance']; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ec33b2de10
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/field_sql_storage_field_storage_delete_instance/7.x
Implement `field_sql_storage_field_storage_delete_instance($instance)` in PHP for Drupal 7. Required behavior: Implements hook_field_storage_delete_instance().
This function simply marks for deletion all data associated with the field. File: modules/field/modules/field_sql_storage/field_sql_storage.module
function field_sql_storage_field_storage_delete_instance($instance) { $field = field_info_field($instance['field_name']); $table_name = _field_sql_storage_tablename($field); $revision_name = _field_sql_storage_revision_tablename($field); db_update($table_name) ->fields(array('deleted' => 1)) ->condition...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ec3f71430a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_delete_node_index/7.x
In Drupal 7, write the function `taxonomy_delete_node_index($node)` (file modules/taxonomy/taxonomy.module) so that it does the following: Deletes taxonomy index entries for a given node.
Parameters: - $node: The node object. File: modules/taxonomy/taxonomy.module
function taxonomy_delete_node_index($node) { if (variable_get('taxonomy_maintain_index_table', TRUE)) { db_delete('taxonomy_index')->condition('nid', $node->nid)->execute(); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ec40a1587b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.admin.inc/function/aggregator_form_opml_submit/7.x
I need the code for `aggregator_form_opml_submit($form, &$form_state)` in Drupal 7 (modules/aggregator/aggregator.admin.inc). It must do this: Form submission handler for aggregator_form_opml().
File: modules/aggregator/aggregator.admin.inc
function aggregator_form_opml_submit($form, &$form_state) { $data = ''; $validators = array('file_validate_extensions' => array('opml xml')); if ($file = file_save_upload('upload', $validators)) { $data = file_get_contents($file->uri); } else { $response = drupal_http_request($form_state['values']['re...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ec4208eeed
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_theme/7.x
Implement `system_theme()` in PHP for Drupal 7. Required behavior: Implements hook_theme().
File: modules/system/system.module
function system_theme() { return array_merge(drupal_common_theme(), array( 'system_themes_page' => array( 'variables' => array('theme_groups' => NULL), 'file' => 'system.admin.inc', ), 'system_settings_form' => array( 'render element' => 'form', ), 'confirm_form' => array( ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-ec669da590
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.install/function/field_sql_storage_update_7001/7.x
In Drupal 7, write the function `field_sql_storage_update_7001(&$sandbox)` (file modules/field/modules/field_sql_storage/field_sql_storage.install) so that it does the following: Remove the field_config_entity_type table and store 'entity_type' strings.
File: modules/field/modules/field_sql_storage/field_sql_storage.install
function field_sql_storage_update_7001(&$sandbox) { if (!isset($sandbox['progress'])) { // Collect current etids. $sandbox['etids'] = db_query('SELECT etid, type FROM {field_config_entity_type}')->fetchAllKeyed(); // Collect affected tables: field data, field revision data, 'deleted' // tables. $...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-ec68d2ccbe
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_rebuild_js/7.x
In Drupal 7, write the function `_locale_rebuild_js($langcode = NULL)` (file includes/locale.inc) so that it does the following: (Re-)Creates the JavaScript translation file for a language.
Parameters: - $language: The language, the translation file should be (re)created for. File: includes/locale.inc
function _locale_rebuild_js($langcode = NULL) { if (!isset($langcode)) { global $language; } else { // Get information about the locale. $languages = language_list(); $language = $languages[$langcode]; } // Construct the array for JavaScript translations. // Only add strings with a translat...
[ "code-task", "function" ]
2026-09-30T00:00:00