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-54ce1fe57c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.install/function/filter_update_7009/7.x | Implement `filter_update_7009()` in PHP for Drupal 7. Required behavior: Converts fields that store serialized variables from text to blob. | File: modules/filter/filter.install | function filter_update_7009() {
$schema = system_schema_cache_7054();
db_drop_table('cache_filter');
db_create_table('cache_filter', $schema);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-54db16dbef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_sort_weight/7.x | In Drupal 7, write the function `drupal_sort_weight($a, $b)` (file includes/common.inc) so that it does the following: Sorts a structured array by the 'weight' element. | Note that the sorting is by the 'weight' array element, not by the render element property '#weight'.
Callback for uasort() used in various functions.
Parameters:
- $a: First item for comparison. The compared items should be associative arrays that optionally include a 'weight' element. For items without a 'weight' e... | function drupal_sort_weight($a, $b) {
$a_weight = (is_array($a) && isset($a['weight'])) ? $a['weight'] : 0;
$b_weight = (is_array($b) && isset($b['weight'])) ? $b['weight'] : 0;
if ($a_weight == $b_weight) {
return 0;
}
return ($a_weight < $b_weight) ? -1 : 1;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-54e185a8f7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_form_user_profile_form_alter/7.x | I need the code for `block_form_user_profile_form_alter(&$form, &$form_state)` in Drupal 7 (modules/block/block.module). It must do this: Implements hook_form_FORM_ID_alter() for user_profile_form(). | File: modules/block/block.module | function block_form_user_profile_form_alter(&$form, &$form_state) {
if ($form['#user_category'] == 'account') {
$account = $form['#user'];
$rids = array_keys($account->roles);
$result = db_query("SELECT DISTINCT b.* FROM {block} b LEFT JOIN {block_role} r ON b.module = r.module AND b.delta = r.delta WHERE... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-54e1c16cd6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/_node_add_access/7.x | Implement `_node_add_access()` in PHP for Drupal 7. Required behavior: Access callback: Checks whether the user has permission to add a node. | Returns: TRUE if the user has add permission, otherwise FALSE.
File: modules/node/node.module | function _node_add_access() {
$types = node_type_get_types();
foreach ($types as $type) {
if (node_hook($type->type, 'form') && node_access('create', $type->type)) {
return TRUE;
}
}
if (user_access('administer content types')) {
// There are no content types defined that the user has permissi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-54eb6a795a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_tree_page_data/7.x | I need the code for `menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE)` in Drupal 7 (includes/menu.inc). It must do this: Gets the data structure for a named menu tree, based on the current page. | The tree order is maintained by storing each parent in an individual field, see http://drupal.org/node/141866 for more.
Parameters:
- $menu_name: The named menu links to return.
- $max_depth: (optional) The maximum depth of links to retrieve.
- $only_active_trail: (optional) Whether to only return the links in the act... | function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) {
$tree = &drupal_static(__FUNCTION__, array());
// Check if the active trail has been overridden for this menu tree.
$active_path = menu_tree_get_path($menu_name);
// Load the menu item corresponding to the current page.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-54ebc2c408 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/trigger_forms/7.x | Implement `trigger_forms()` in PHP for Drupal 7. Required behavior: Implements hook_forms(). | We re-use code by using the same assignment form definition for each hook.
File: modules/trigger/trigger.module | function trigger_forms() {
$trigger_info = _trigger_get_all_info();
$forms = array();
foreach ($trigger_info as $module => $hooks) {
foreach ($hooks as $hook => $description) {
$forms['trigger_' . $hook . '_assign_form'] = array('callback' => 'trigger_assign_form');
}
}
return $forms;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-55199239b5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.install/function/filter_update_dependencies/7.x | In Drupal 7, write the function `filter_update_dependencies()` (file modules/filter/filter.install) so that it does the following: Implements hook_update_dependencies(). | File: modules/filter/filter.install | function filter_update_dependencies() {
// filter_update_7005() migrates role permissions and therefore must run
// after the {role} and {role_permission} tables are properly set up, which
// happens in user_update_7007().
$dependencies['filter'][7005] = array(
'user' => 7007,
);
return $dependencies;
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-55296bbaa4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.pages.inc/function/contact_personal_form_validate/7.x | In Drupal 7, write the function `contact_personal_form_validate($form, &$form_state)` (file modules/contact/contact.pages.inc) so that it does the following: Form validation handler for contact_personal_form(). | File: modules/contact/contact.pages.inc | function contact_personal_form_validate($form, &$form_state) {
if (!valid_email_address($form_state['values']['mail'])) {
form_set_error('mail', t('You must enter a valid e-mail address.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-552faa7a9a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_rename_bundle/7.x | Implement `field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)` in PHP for Drupal 7. Required behavior: Notify field.module that a bundle was renamed. | Parameters:
- $entity_type: The entity type to which the bundle is bound.
- $bundle_old: The previous name of the bundle.
- $bundle_new: The new name of the bundle.
File: modules/field/field.attach.inc | function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
db_update('field_config_instance')
->fields(array('bundle' => $bundle_new))
->condition('entity_type', $entity_type)
->condition('bundle', $bundle_old)
->execute();
// Clear the cache.
field_cache_clear();
// Update ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5532c3db07 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_translation_filter_form/7.x | Implement `locale_translation_filter_form()` in PHP for Drupal 7. Required behavior: Return form for locale translation filters. | File: modules/locale/locale.admin.inc | function locale_translation_filter_form() {
$filters = locale_translation_filters();
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Filter translatable strings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
foreach ($filters as $key => $filter) {
// Special case for '... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-55554aae2c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_prepare_predefined_list/7.x | Implement `_locale_prepare_predefined_list()` in PHP for Drupal 7. Required behavior: Prepares the language code list for a select form item with only the unsupported ones | File: includes/locale.inc | function _locale_prepare_predefined_list() {
include_once DRUPAL_ROOT . '/includes/iso.inc';
$languages = language_list();
$predefined = _locale_get_predefined_list();
foreach ($predefined as $key => $value) {
if (isset($languages[$key])) {
unset($predefined[$key]);
continue;
}
// Includ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5555f39e66 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_modules_uninstalled/7.x | In Drupal 7, show an example implementation for `hook_modules_uninstalled($modules)` (modules/system/system.api.php): Perform necessary actions after modules are uninstalled. | This function differs from hook_uninstall() in that it gives all other modules a chance to perform actions when a module is uninstalled, whereas hook_uninstall() is only called on the module actually being uninstalled.
It is recommended that you implement this hook if your module stores data that may have been set by ... | function hook_modules_uninstalled($modules) {
foreach ($modules as $module) {
db_delete('mymodule_table')
->condition('module', $module)
->execute();
}
mymodule_cache_rebuild();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-556ce4bc06 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_update/7.x | In Drupal 7, write the function `poll_update($node)` (file modules/poll/poll.module) so that it does the following: Implements hook_update(). | File: modules/poll/poll.module | function poll_update($node) {
// Update poll settings.
db_update('poll')
->fields(array(
'runtime' => $node->runtime,
'active' => $node->active,
))
->condition('nid', $node->nid)
->execute();
// Poll choices with empty titles signifies removal. We remove all votes to
// the removed ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-556d208da5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_user_logout/7.x | Implement `openid_user_logout($account)` in PHP for Drupal 7. Required behavior: Implements hook_user_logout(). | Delete any openid_identifier in visitor cookie.
File: modules/openid/openid.module | function openid_user_logout($account) {
if (isset($_COOKIE['Drupal_visitor_openid_identifier'])) {
user_cookie_delete('openid_identifier');
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-556d6498f6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/aggregator_page_category/7.x | Implement `aggregator_page_category($category)` in PHP for Drupal 7. Required behavior: Page callback: Displays all the items aggregated in a particular category. | Parameters:
- $category: The category for which to list all of the aggregated items.
Returns: The rendered list of items for the feed.
File: modules/aggregator/aggregator.pages.inc | function aggregator_page_category($category) {
drupal_add_feed('aggregator/rss/' . $category['cid'], variable_get('site_name', 'Drupal') . ' ' . t('aggregator - @title', array('@title' => $category['title'])));
// It is safe to include the cid in the query because it's loaded from the
// database by aggregator_c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-557bafdcf9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.api.php/function/hook_taxonomy_term_insert/7.x | Give me the example code for `hook_taxonomy_term_insert($term)` in Drupal 7. Hook description: Act on taxonomy terms when inserted. | Modules implementing this hook can act on the term object when saved to the database.
Parameters:
- $term: A taxonomy term object.
File: modules/taxonomy/taxonomy.api.php | function hook_taxonomy_term_insert($term) {
db_insert('mytable')
->fields(array(
'tid' => $term->tid,
'foo' => $term->foo,
))
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-5592c0b158 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_menu/7.x | Implement `openid_menu()` in PHP for Drupal 7. Required behavior: Implements hook_menu(). | File: modules/openid/openid.module | function openid_menu() {
$items['openid/authenticate'] = array(
'title' => 'OpenID Login',
'page callback' => 'openid_authentication_page',
'access callback' => 'user_is_anonymous',
'type' => MENU_CALLBACK,
'file' => 'openid.pages.inc',
);
$items['user/%user/openid'] = array(
'title' => 'O... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-55e0d9a08f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.module/function/path_form_taxonomy_form_term_alter/7.x | Implement `path_form_taxonomy_form_term_alter(&$form, $form_state)` in PHP for Drupal 7. Required behavior: Implements hook_form_FORM_ID_alter() for taxonomy_form_term(). | File: modules/path/path.module | function path_form_taxonomy_form_term_alter(&$form, $form_state) {
// Make sure this does not show up on the delete confirmation form.
if (empty($form_state['confirm_delete'])) {
$langcode = entity_language('taxonomy_term', (object) $form['#term']);
$langcode = !empty($langcode) ? $langcode : LANGUAGE_NONE;... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-55ef708e90 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_mkdir/7.x | Implement `drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL)` in PHP for Drupal 7. Required behavior: Creates a directory, optionally creating missing components in the path to the directory. | When PHP's mkdir() creates a directory, the requested mode is affected by the process's umask. This function overrides the umask and sets the mode explicitly for all directory components created.
Parameters:
- $uri: A URI or pathname.
- $mode: Mode given to created directories. Defaults to the directory mode configure... | function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
if (!isset($mode)) {
$mode = variable_get('file_chmod_directory', 0775);
}
// If the URI has a scheme, don't override the umask - schemes can handle this
// issue in their own implementation.
if (file_uri_scheme($uri)) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-55f4ca9f05 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_get_topics/7.x | In Drupal 7, write the function `forum_get_topics($tid, $sortby, $forum_per_page)` (file modules/forum/forum.module) so that it does the following: Gets all the topics in a forum. | Parameters:
- $tid: The term ID of the forum.
- $sortby: One of the following integers indicating the sort criteria: - 1: Date - newest first. - 2: Date - oldest first. - 3: Posts with the most comments first. - 4: Posts with the least comments first.
- $forum_per_page: The maximum number of topics to display per page.... | function forum_get_topics($tid, $sortby, $forum_per_page) {
global $user, $forum_topic_list_header;
$forum_topic_list_header = array(
NULL,
array('data' => t('Topic'), 'field' => 'f.title'),
array('data' => t('Replies'), 'field' => 'f.comment_count'),
array('data' => t('Last reply'), 'field' => 'f.... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5605c71dbc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_bundles/7.x | In Drupal 7, write the function `field_info_bundles($entity_type = NULL)` (file modules/field/field.info.inc) so that it does the following: Returns information about existing bundles. | Parameters:
- $entity_type: The type of entity; e.g. 'node' or 'user'.
Returns: An array of bundles for the $entity_type keyed by bundle name, or, if no $entity_type was provided, the array of all existing bundles, keyed by entity type.
File: modules/field/field.info.inc | function field_info_bundles($entity_type = NULL) {
$info = entity_get_info();
if ($entity_type) {
return isset($info[$entity_type]['bundles']) ? $info[$entity_type]['bundles'] : array();
}
$bundles = array();
foreach ($info as $type => $entity_info) {
$bundles[$type] = $entity_info['bundles'];
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5615db9dd9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.admin.inc/function/profile_field_form_submit/7.x | I need the code for `profile_field_form_submit($form, &$form_state)` in Drupal 7 (modules/profile/profile.admin.inc). It must do this: Process profile_field_form submissions. | File: modules/profile/profile.admin.inc | function profile_field_form_submit($form, &$form_state) {
if (!isset($form_state['values']['options'])) {
$form_state['values']['options'] = '';
}
if (!isset($form_state['values']['page'])) {
$form_state['values']['page'] = '';
}
// Remove all elements that are not profile_field columns.
$values = a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-56174e6fca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_cancel/7.x | Implement `poll_cancel($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit callback for poll_cancel_form(). | File: modules/poll/poll.module | function poll_cancel($form, &$form_state) {
global $user;
$node = node_load($form['#nid']);
db_delete('poll_vote')
->condition('nid', $node->nid)
->condition($user->uid ? 'uid' : 'hostname', $user->uid ? $user->uid : ip_address())
->execute();
// Subtract from the votes.
db_update('poll_choice')... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5620926566 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_init/7.x | Give me the example code for `hook_init()` in Drupal 7. Hook description: Perform setup tasks for non-cached page requests. | This hook is run at the beginning of the page request. It is typically used to set up global parameters that are needed later in the request. When this hook is called, the theme and all modules are already loaded in memory.
This hook is not run on cached pages.
To add CSS or JS files that should be present on all pag... | function hook_init() {
// Since this file should only be loaded on the front page, it cannot be
// declared in the info file.
if (drupal_is_front_page()) {
drupal_add_css(drupal_get_path('module', 'foo') . '/foo.css');
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-56213f2663 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_extract_allowed_values/7.x | In Drupal 7, write the function `list_extract_allowed_values($string, $field_type, $generate_keys)` (file modules/field/modules/list/list.module) so that it does the following: Parses a string of 'allowed values' into an array. | Parameters:
- $string: The list of allowed values in string format described in list_allowed_values_string().
- $field_type: The field type. Either 'list_number' or 'list_text'.
- $generate_keys: Boolean value indicating whether to generate keys based on the position of the value if a key is not manually specified, and... | function list_extract_allowed_values($string, $field_type, $generate_keys) {
$values = array();
$list = explode("\n", $string);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
$generated_keys = $explicit_keys = FALSE;
foreach ($list as $position => $text) {
$value = $key = FAL... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5635e76f6b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpcs.inc/function/xmlrpc_server_list_methods/7.x | In Drupal 7, write the function `xmlrpc_server_list_methods()` (file includes/xmlrpcs.inc) so that it does the following: Lists the methods available on this XML-RPC server. | XML-RPC method system.listMethods maps to this function.
Returns (array): Array of the names of methods available on this server.
File: includes/xmlrpcs.inc | function xmlrpc_server_list_methods() {
$xmlrpc_server = xmlrpc_server_get();
return array_keys($xmlrpc_server->callbacks);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5648e727d4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/update.php/function/update_access_allowed/7.x | In Drupal 7, write the function `update_access_allowed()` (file update.php) so that it does the following: Determines if the current user is allowed to run update.php. | Returns: TRUE if the current user should be granted access, or FALSE otherwise.
File: update.php | function update_access_allowed() {
global $update_free_access, $user;
// Allow the global variable in settings.php to override the access check.
if (!empty($update_free_access)) {
return TRUE;
}
// Calls to user_access() might fail during the Drupal 6 to 7 update process,
// so we fall back on requirin... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5654b4fce9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.module/function/contact_mail/7.x | In Drupal 7, write the function `contact_mail($key, &$message, $params)` (file modules/contact/contact.module) so that it does the following: Implements hook_mail(). | File: modules/contact/contact.module | function contact_mail($key, &$message, $params) {
$language = $message['language'];
$variables = array(
'!site-name' => variable_get('site_name', 'Drupal'),
'!subject' => $params['subject'],
'!category' => isset($params['category']['category']) ? $params['category']['category'] : '',
'!form-url' => ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-565c53bcc5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_promote_action/7.x | In Drupal 7, write the function `node_promote_action($node, $context = array())` (file modules/node/node.module) so that it does the following: Sets the promote property of a node to 1. | Parameters:
- $node: A node object.
- $context: (optional) Array of additional information about what triggered the action. Not used for this action.
File: modules/node/node.module | function node_promote_action($node, $context = array()) {
$node->promote = NODE_PROMOTED;
watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_type_get_name($node), '%title' => $node->title));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-566ef7740c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/_options_properties/7.x | In Drupal 7, write the function `_options_properties($type, $multiple, $required, $has_value)` (file modules/field/modules/options/options.module) so that it does the following: Describes the preparation steps required by each widget. | File: modules/field/modules/options/options.module | function _options_properties($type, $multiple, $required, $has_value) {
$base = array(
'filter_xss' => FALSE,
'strip_tags' => FALSE,
'strip_tags_and_unescape' => FALSE,
'empty_option' => FALSE,
'optgroups' => FALSE,
);
$properties = array();
switch ($type) {
case 'select':
$prope... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-568845e3cc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_link_delete/7.x | In Drupal 7, show an example implementation for `hook_menu_link_delete($link)` (modules/system/system.api.php): Inform modules that a menu link has been deleted. | This hook is used to notify modules that menu items have been deleted. Contributed modules may use the information to perform actions based on the information entered into the menu system.
Parameters:
- $link: Associative array defining a menu link as passed into menu_link_save().
File: modules/system/system.api.php | function hook_menu_link_delete($link) {
// Delete the record from our table.
db_delete('menu_example')
->condition('mlid', $link['mlid'])
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-5697f589e4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_field_formatter_view/7.x | In Drupal 7, write the function `text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)` (file modules/field/modules/text/text.module) so that it does the following: Implements hook_field_formatter_view(). | File: modules/field/modules/text/text.module | function text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'text_default':
case 'text_trimmed':
foreach ($items as $delta => $item) {
$output = _text_sanitize($instance, $langcode, $item, 'va... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-56a1fa6581 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_view_voting_validate/7.x | In Drupal 7, write the function `poll_view_voting_validate($form, &$form_state)` (file modules/poll/poll.module) so that it does the following: Validation function for processing votes | File: modules/poll/poll.module | function poll_view_voting_validate($form, &$form_state) {
if (empty($form_state['values']['choice'])) {
form_set_error( 'choice', t('Your vote could not be recorded because you did not select any of the choices.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-56d8d82353 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_form_block_admin_configure_alter/7.x | Implement `dashboard_form_block_admin_configure_alter(&$form, &$form_state)` in PHP for Drupal 7. Required behavior: Implements hook_form_FORM_ID_alter(). | File: modules/dashboard/dashboard.module | function dashboard_form_block_admin_configure_alter(&$form, &$form_state) {
global $theme_key;
drupal_theme_initialize();
// Hide the dashboard regions from the region select list on the block
// configuration form, for all themes except the current theme (since the
// other themes do not display the dashboar... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-56d902cf7b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/theme_menu_admin_overview/7.x | I need the code for `theme_menu_admin_overview($variables)` in Drupal 7 (modules/menu/menu.admin.inc). It must do this: Returns HTML for a menu title and description for the menu overview page. | Parameters:
- $variables: An associative array containing: - title: The menu's title. - description: The menu's description.
File: modules/menu/menu.admin.inc | function theme_menu_admin_overview($variables) {
$output = check_plain($variables['title']);
$output .= '<div class="description">' . filter_xss_admin($variables['description']) . '</div>';
return $output;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-56ec032c00 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/locale_add_language/7.x | Implement `locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE)` in PHP for Drupal 7. Required behavior: API function to add a language. | Parameters:
- $langcode: Language code.
- $name: English name of the language
- $native: Native name of the language
- $direction: LANGUAGE_LTR or LANGUAGE_RTL
- $domain: Optional custom domain name with protocol, without trailing slash (eg. http://de.example.com).
- $prefix: Optional path prefix for the language. Defa... | function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) {
// Default prefix on language code.
if (empty($prefix)) {
$prefix = $langcode;
}
// If name was not set, we add a predefined language.
if (!iss... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-56f01879db | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_search_status/7.x | Implement `node_search_status()` in PHP for Drupal 7. Required behavior: Implements hook_search_status(). | File: modules/node/node.module | function node_search_status() {
$total = db_query('SELECT COUNT(*) FROM {node}')->fetchField();
$remaining = db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0")->fetchField();
return array('remaining' => $remaining, 'tot... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-5703529dfa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_node_delete/7.x | Implement `taxonomy_node_delete($node)` in PHP for Drupal 7. Required behavior: Implements hook_node_delete(). | File: modules/taxonomy/taxonomy.module | function taxonomy_node_delete($node) {
// Clean up the {taxonomy_index} table when nodes are deleted.
taxonomy_delete_node_index($node);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-571488b7e8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_boolean_allowed_values_callback/7.x | I need the code for `list_boolean_allowed_values_callback($element, $input, $form_state)` in Drupal 7 (modules/field/modules/list/list.module). It must do this: Form element #value_callback: assembles the allowed values for 'boolean' fields. | File: modules/field/modules/list/list.module | function list_boolean_allowed_values_callback($element, $input, $form_state) {
$on = drupal_array_get_nested_value($form_state['input'], $element['#on_parents']);
$off = drupal_array_get_nested_value($form_state['input'], $element['#off_parents']);
return array($off, $on);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5714f6114c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_stream_wrapper_get_instance_by_uri/7.x | Implement `file_stream_wrapper_get_instance_by_uri($uri)` in PHP for Drupal 7. Required behavior: Returns a reference to the stream wrapper class responsible for a given URI. | The scheme determines the stream wrapper class that should be used by consulting the stream wrapper registry.
Parameters:
- $uri: A stream, referenced as "scheme://target".
Returns: Returns a new stream wrapper object appropriate for the given URI or FALSE if no registered handler could be found. For example, a URI o... | function file_stream_wrapper_get_instance_by_uri($uri) {
$scheme = file_uri_scheme($uri);
$class = file_stream_wrapper_get_class($scheme);
if (class_exists($class)) {
$instance = new $class();
$instance->setUri($uri);
return $instance;
}
else {
return FALSE;
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5730474b39 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_type_set_defaults/7.x | Implement `node_type_set_defaults($info = array())` in PHP for Drupal 7. Required behavior: Sets the default values for a node type. | The defaults are appropriate for a type defined through hook_node_info(), since 'custom' is TRUE for types defined in the user interface, and FALSE for types defined by modules. (The 'custom' flag prevents types from being deleted through the user interface.) Also, the default for 'locked' is TRUE, which prevents users... | function node_type_set_defaults($info = array()) {
$info = (array) $info;
$new_type = $info + array(
'type' => '',
'name' => '',
'base' => '',
'description' => '',
'help' => '',
'custom' => 0,
'modified' => 0,
'locked' => 1,
'disabled' => 0,
'is_new' => 1,
'has_title' => ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5732bb3a98 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_after/7.x | I need the code for `ajax_command_after($selector, $html, $settings = NULL)` in Drupal 7 (includes/ajax.inc). It must do this: Creates a Drupal Ajax 'insert/after' command. | The 'insert/after' command instructs the client to use jQuery's after() method to insert the given HTML content after each element matched by the given selector.
This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.
Parameters:
- $selector: A jQuery selector string. If the co... | function ajax_command_after($selector, $html, $settings = NULL) {
return array(
'command' => 'insert',
'method' => 'after',
'selector' => $selector,
'data' => $html,
'settings' => $settings,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5739b98da9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/_trigger_get_all_info/7.x | I need the code for `_trigger_get_all_info()` in Drupal 7 (modules/trigger/trigger.module). It must do this: Retrieves and caches information from hook_trigger_info() implementations. | Returns (Array): of all triggers.
File: modules/trigger/trigger.module | function _trigger_get_all_info() {
$triggers = &drupal_static(__FUNCTION__);
if (!isset($triggers)) {
$triggers = module_invoke_all('trigger_info');
drupal_alter('trigger_info', $triggers);
}
return $triggers;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-573d9a63ab | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_display/7.x | In Drupal 7, write the function `field_get_display($instance, $view_mode, $entity)` (file modules/field/field.module) so that it does the following: Returns the display settings to use for an instance in a given view mode. | Parameters:
- $instance: The field instance being displayed.
- $view_mode: The view mode.
- $entity: The entity being displayed.
Returns: The display settings to be used when displaying the field values.
File: modules/field/field.module | function field_get_display($instance, $view_mode, $entity) {
// Check whether the view mode uses custom display settings or the 'default'
// mode.
$view_mode_settings = field_view_mode_settings($instance['entity_type'], $instance['bundle']);
$actual_mode = (!empty($view_mode_settings[$view_mode]['custom_setting... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5755b5f1e8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.install/function/comment_enable/7.x | In Drupal 7, write the function `comment_enable()` (file modules/comment/comment.install) so that it does the following: Implements hook_enable(). | File: modules/comment/comment.install | function comment_enable() {
// Insert records into the node_comment_statistics for nodes that are missing.
$query = db_select('node', 'n');
$query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid');
$query->addField('n', 'created', 'last_comment_timestamp');
$query->addField('n', 'uid', 'last_comm... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-5758880779 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_bootstrap_database/7.x | Implement `_drupal_bootstrap_database()` in PHP for Drupal 7. Required behavior: Initializes the database system and registers autoload functions. | File: includes/bootstrap.inc | function _drupal_bootstrap_database() {
// Redirect the user to the installation script if Drupal has not been
// installed yet (i.e., if no $databases array has been defined in the
// settings.php file) and we are not already installing.
if (empty($GLOBALS['databases']) && !drupal_installation_attempted()) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-57683d58e2 | 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_query/7.x | In Drupal 7, write the function `field_sql_storage_field_storage_query(EntityFieldQuery $query)` (file modules/field/modules/field_sql_storage/field_sql_storage.module) so that it does the following: Implements hook_field_storage_query(). | File: modules/field/modules/field_sql_storage/field_sql_storage.module | function field_sql_storage_field_storage_query(EntityFieldQuery $query) {
if ($query->age == FIELD_LOAD_CURRENT) {
$tablename_function = '_field_sql_storage_tablename';
$id_key = 'entity_id';
}
else {
$tablename_function = '_field_sql_storage_revision_tablename';
$id_key = 'revision_id';
}
$ta... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-577eee4820 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7016/7.x | Implement `system_update_7016()` in PHP for Drupal 7. Required behavior: Remove custom datatype *_unsigned in PostgreSQL. | File: modules/system/system.install | function system_update_7016() {
// Only run these queries if the driver used is pgsql.
if (db_driver() == 'pgsql') {
$result = db_query("SELECT c.relname AS table, a.attname AS field,
pg_catalog.format_type(a.atttypid, a.atttypmod) AS type
FROM pg_catalog.pg_attri... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5785113814 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_block_list_alter/7.x | I need the code for `overlay_block_list_alter(&$blocks)` in Drupal 7 (modules/overlay/overlay.module). It must do this: Implements hook_block_list_alter(). | File: modules/overlay/overlay.module | function overlay_block_list_alter(&$blocks) {
// If we are limiting rendering to a subset of page regions, hide all blocks
// which appear in regions not on that list. Note that overlay_page_alter()
// does a more comprehensive job of preventing unwanted regions from being
// displayed (regardless of whether th... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-57e2dff80b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_ajax_upload/7.x | I need the code for `file_ajax_upload()` in Drupal 7 (modules/file/file.module). It must do this: Menu callback; Shared Ajax callback for file uploads and deletions. | This rebuilds the form element for a particular field item. As long as the form processing is properly encapsulated in the widget element the form should rebuild correctly using FAPI without the need for additional callbacks or processing.
File: modules/file/file.module | function file_ajax_upload() {
$form_parents = func_get_args();
$form_build_id = (string) array_pop($form_parents);
// Sanitize form parents before using them.
$form_parents = array_filter($form_parents, 'element_child');
if (empty($_POST['form_build_id']) || $form_build_id != $_POST['form_build_id']) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-57fd06649c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/_system_date_formats_build/7.x | Implement `_system_date_formats_build()` in PHP for Drupal 7. Required behavior: Builds and returns information about available date formats. | Returns: An associative array of date formats. The top-level keys are the names of the date types that the date formats belong to. The values are in turn associative arrays keyed by format with the following keys: - dfid: The date format ID. - format: The PHP date format string. - type: The machine-readable name of the... | function _system_date_formats_build() {
$date_formats = array();
// First handle hook_date_format_types().
$types = _system_date_format_types_build();
foreach ($types as $type => $info) {
system_date_format_type_save($info);
}
// Get formats supplied by various contrib modules.
$module_formats = mod... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-58080b7c89 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_delete_confirm_submit/7.x | I need the code for `node_delete_confirm_submit($form, &$form_state)` in Drupal 7 (modules/node/node.pages.inc). It must do this: Executes node deletion. | File: modules/node/node.pages.inc | function node_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
$node = node_load($form_state['values']['nid']);
node_delete($form_state['values']['nid']);
cache_clear_all();
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $nod... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-583fa02fab | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_login_finalize/7.x | I need the code for `user_login_finalize(&$form_state = array())` in Drupal 7 (modules/user/user.module). It must do this: Finalize the login process. Must be called when logging in a user. | The function records a watchdog message about the new session, saves the login timestamp, calls hook_user_login(), and generates a new session.
Parameters:
- $form_state (array): A keyed array containing the current state of the login form.
File: modules/user/user.module | function user_login_finalize(&$form_state = array()) {
global $user;
watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
// Update the user table timestamp noting user has logged in.
// This is also used to invalidate one-time login links.
$user->login = REQUEST_TIME;
db_update('us... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5875fc6540 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_unblock_user_action/7.x | I need the code for `user_unblock_user_action(&$entity, $context = array())` in Drupal 7 (modules/user/user.module). It must do this: Unblocks a specific user or the current user, if one is not specified. | Parameters:
- $entity: (optional) An entity object; if it is provided and it has a uid property, the user with that ID is unblocked.
- $context: (optional) An associative array; if no user ID is found in $entity, the 'uid' element of this array determines the user to unblock.
File: modules/user/user.module | function user_unblock_user_action(&$entity, $context = array()) {
// First priority: If there is a $entity->uid, unblock that user.
// This is most likely a user object or the author if a node or comment.
if (isset($entity->uid)) {
$uid = $entity->uid;
}
elseif (isset($context['uid'])) {
$uid = $conte... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-587c1c34c9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_get_messages/7.x | I need the code for `drupal_get_messages($type = NULL, $clear_queue = TRUE)` in Drupal 7 (includes/bootstrap.inc). It must do this: Returns all messages that have been set with drupal_set_message(). | Parameters:
- $type (string): (optional) Limit the messages returned by type. Defaults to NULL, meaning all types. These values are supported: - NULL - 'status' - 'warning' - 'error'
- $clear_queue (bool): (optional) If this is TRUE, the queue will be cleared of messages of the type specified in the $type parameter. Ot... | function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
if ($messages = drupal_set_message()) {
if ($type) {
if ($clear_queue) {
unset($_SESSION['messages'][$type]);
}
if (isset($messages[$type])) {
return array($type => $messages[$type]);
}
}
else {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-58873a5a81 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.install/function/field_update_7002/7.x | Implement `field_update_7002()` in PHP for Drupal 7. Required behavior: Split the all-inclusive field_bundle_settings variable per bundle. | File: modules/field/field.install | function field_update_7002() {
$settings = variable_get('field_bundle_settings', array());
if ($settings) {
foreach ($settings as $entity_type => $entity_type_settings) {
foreach ($entity_type_settings as $bundle => $bundle_settings) {
variable_set('field_bundle_settings_' . $entity_type . '__' . ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-588a354035 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_delete/7.x | Implement `db_delete($table, array $options = array())` in PHP for Drupal 7. Required behavior: Returns a new DeleteQuery object for the active database. | Parameters:
- $table: The table from which to delete.
- $options: An array of options to control how the query operates.
Returns: DeleteQuery A new DeleteQuery object for this connection.
File: includes/database/database.inc | function db_delete($table, array $options = array()) {
if (empty($options['target']) || $options['target'] == 'slave') {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->delete($table, $options);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5893567544 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_site_status_alter/7.x | In Drupal 7, show an example implementation for `hook_menu_site_status_alter(&$menu_site_status, $path)` (modules/system/system.api.php): Control site status before menu dispatching. | The hook is called after checking whether the site is offline but before the current router item is retrieved and executed by menu_execute_active_handler(). If the site is in offline mode, $menu_site_status is set to MENU_SITE_OFFLINE.
Parameters:
- $menu_site_status: Supported values are MENU_SITE_OFFLINE, MENU_ACCES... | function hook_menu_site_status_alter(&$menu_site_status, $path) {
// Allow access to my_module/authentication even if site is in offline mode.
if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'my_module/authentication') {
$menu_site_status = MENU_SITE_ONLINE;
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-58a265b4ba | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.install/function/filter_install/7.x | In Drupal 7, write the function `filter_install()` (file modules/filter/filter.install) so that it does the following: Implements hook_install(). | File: modules/filter/filter.install | function filter_install() {
// All sites require at least one text format (the fallback format) that all
// users have access to, so add it here. We initialize it as a simple, safe
// plain text format with very basic formatting, but it can be modified by
// installation profiles to have other properties.
$pl... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-58a78a9086 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21blog%21blog.module/function/blog_rdf_mapping/7.x | I need the code for `blog_rdf_mapping()` in Drupal 7 (modules/blog/blog.module). It must do this: Implements hook_rdf_mapping(). | File: modules/blog/blog.module | function blog_rdf_mapping() {
return array(
array(
'type' => 'node',
'bundle' => 'blog',
'mapping' => array(
'rdftype' => array('sioc:Post', 'sioct:BlogPost'),
),
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-58a7b0cf35 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_node_update/7.x | In Drupal 7, write the function `translation_node_update($node)` (file modules/translation/translation.module) so that it does the following: Implements hook_node_update(). | File: modules/translation/translation.module | function translation_node_update($node) {
// Only act if we are dealing with a content type supporting translations.
if (translation_supported_type($node->type)) {
$langcode = entity_language('node', $node);
if (isset($node->translation) && $node->translation && !empty($langcode) && $node->tnid) {
// ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-58b6e367c1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.install/function/menu_update_7002/7.x | Implement `menu_update_7002(&$sandbox)` in PHP for Drupal 7. Required behavior: Rename the primary/secondary menu blocks to match previously renamed menus. | File: modules/menu/menu.install | function menu_update_7002(&$sandbox) {
// Check for the presence of old or new table names.
if (db_table_exists('blocks') || db_table_exists('block')) {
$renamed_deltas = array(
'menu' => array(
'primary-links' => 'main-menu',
'secondary-links' => 'secondary-menu',
),
);
$mo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-58c8251aac | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.api.php/function/hook_search_reset/7.x | In Drupal 7, show an example implementation for `hook_search_reset()` (modules/search/search.api.php): Take action when the search index is going to be rebuilt. | Modules that use hook_update_index() should update their indexing bookkeeping so that it starts from scratch the next time hook_update_index() is called.
File: modules/search/search.api.php | function hook_search_reset() {
db_update('search_dataset')
->fields(array('reindex' => REQUEST_TIME))
->condition('type', 'node')
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-58ce9a973f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_icon_map/7.x | Implement `file_icon_map($file)` in PHP for Drupal 7. Required behavior: Determines the generic icon MIME package based on a file's MIME type. | Parameters:
- $file: A file object.
Returns: The generic icon MIME package expected for this file.
File: modules/file/file.module | function file_icon_map($file) {
switch ($file->filemime) {
// Word document types.
case 'application/msword':
case 'application/vnd.ms-word.document.macroEnabled.12':
case 'application/vnd.oasis.opendocument.text':
case 'application/vnd.oasis.opendocument.text-template':
case 'application/vnd.... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-58d7b48613 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.pages.inc/function/simpletest_result_get/7.x | I need the code for `simpletest_result_get($test_id)` in Drupal 7 (modules/simpletest/simpletest.pages.inc). It must do this: Get test results for $test_id. | Parameters:
- $test_id: The test_id to retrieve results of.
Returns (Array): of results grouped by test_class.
File: modules/simpletest/simpletest.pages.inc | function simpletest_result_get($test_id) {
$results = db_select('simpletest')
->fields('simpletest')
->condition('test_id', $test_id)
->orderBy('test_class')
->orderBy('message_id')
->execute();
$test_results = array();
foreach ($results as $result) {
if (!isset($test_results[$result->tes... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-58db5ce3ad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21lock.inc/function/_lock_id/7.x | I need the code for `_lock_id()` in Drupal 7 (includes/lock.inc). It must do this: Helper function to get this request's unique id. | File: includes/lock.inc | function _lock_id() {
// Do not use drupal_static(). This identifier refers to the current
// client request, and must not be changed under any circumstances
// else the shutdown handler may fail to release our locks.
static $lock_id;
if (!isset($lock_id)) {
// Assign a unique id.
$lock_id = uniqid(m... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-58dee9ab79 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_delete_menu_confirm_submit/7.x | Implement `menu_delete_menu_confirm_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Delete a custom menu and all links in it. | File: modules/menu/menu.admin.inc | function menu_delete_menu_confirm_submit($form, &$form_state) {
$menu = $form['#menu'];
$form_state['redirect'] = 'admin/structure/menu';
// System-defined menus may not be deleted - only menus defined by this module.
$system_menus = menu_list_system_menus();
if (isset($system_menus[$menu['menu_name']]) || ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-58e8b7c41c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_node_delete/7.x | I need the code for `book_node_delete($node)` in Drupal 7 (modules/book/book.module). It must do this: Implements hook_node_delete(). | File: modules/book/book.module | function book_node_delete($node) {
if (!empty($node->book['bid'])) {
if ($node->nid == $node->book['bid']) {
// Handle deletion of a top-level post.
$result = db_query("SELECT b.nid FROM {menu_links} ml INNER JOIN {book} b on b.mlid = ml.mlid WHERE ml.plid = :plid", array(
':plid' => $node->bo... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-5906bc8e97 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_get_suggestions/7.x | Implement `theme_get_suggestions($args, $base, $delimiter = '__')` in PHP for Drupal 7. Required behavior: Generate an array of suggestions from path arguments. | This is typically called for adding to the 'theme_hook_suggestions' or 'classes_array' variables from within preprocess functions, when wanting to base the additional suggestions on the path of the current page.
Parameters:
- $args: An array of path arguments, such as from function arg().
- $base: A string identifying... | function theme_get_suggestions($args, $base, $delimiter = '__') {
// Build a list of suggested theme hooks or body classes in order of
// specificity. One suggestion is made for every element of the current path,
// though numeric elements are not carried to subsequent suggestions. For
// example, for $base='p... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5934c62887 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_js_alter/7.x | I need the code for `locale_js_alter(&$javascript)` in Drupal 7 (modules/locale/locale.module). It must do this: Implements hook_js_alter(). | This function checks all JavaScript files currently added via drupal_add_js() and invokes parsing if they have not yet been parsed for Drupal.t() and Drupal.formatPlural() calls. Also refreshes the JavaScript translation file if necessary, and adds it to the page.
File: modules/locale/locale.module | function locale_js_alter(&$javascript) {
global $language;
$dir = 'public://' . variable_get('locale_js_directory', 'languages');
$parsed = variable_get('javascript_parsed', array());
$files = $new_files = FALSE;
// Require because locale_js_alter() could be called without locale_init().
require_once DRUP... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-594371b0ec | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_form_process_password_confirm/7.x | Implement `user_form_process_password_confirm($element)` in PHP for Drupal 7. Required behavior: Form element process handler for client-side password validation. | This #process handler is automatically invoked for 'password_confirm' form elements to add the JavaScript and string translations for dynamic password validation.
File: modules/user/user.module | function user_form_process_password_confirm($element) {
global $user;
$js_settings = array(
'password' => array(
'strengthTitle' => t('Password strength:'),
'hasWeaknesses' => t('To make your password stronger:'),
'tooShort' => t('Make it at least 6 characters'),
'addLowerCase' => t('Ad... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-594758d060 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.fetch.inc/function/_update_create_fetch_task/7.x | In Drupal 7, write the function `_update_create_fetch_task($project)` (file modules/update/update.fetch.inc) so that it does the following: Adds a task to the queue for fetching release history data for a project. | We only create a new fetch task if there's no task already in the queue for this particular project (based on 'fetch_task::' entries in the {cache_update} table).
Parameters:
- $project: Associative array of information about a project as created by update_get_projects(), including keys such as 'name' (short name), an... | function _update_create_fetch_task($project) {
$fetch_tasks = &drupal_static(__FUNCTION__, array());
if (empty($fetch_tasks)) {
$fetch_tasks = _update_get_cache_multiple('fetch_task');
}
$cid = 'fetch_task::' . $project['name'];
if (empty($fetch_tasks[$cid])) {
$queue = DrupalQueue::get('update_fetch_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-594e60bf13 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_node_validate/7.x | I need the code for `translation_node_validate($node, $form)` in Drupal 7 (modules/translation/translation.module). It must do this: Implements hook_node_validate(). | Ensures that duplicate translations can't be created for the same source.
File: modules/translation/translation.module | function translation_node_validate($node, $form) {
// Only act on translatable nodes with a tnid or translation_source.
if (translation_supported_type($node->type) && (!empty($node->tnid) || !empty($form['#node']->translation_source->nid))) {
$tnid = !empty($node->tnid) ? $node->tnid : $form['#node']->translati... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-59c26950d6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_is_page/7.x | Implement `node_is_page($node)` in PHP for Drupal 7. Required behavior: Returns whether the current page is the full page view of the passed-in node. | Parameters:
- $node: A node object.
Returns: The ID of the node if this is a full page view, otherwise FALSE.
File: modules/node/node.module | function node_is_page($node) {
$page_node = menu_get_object();
return (!empty($page_node) ? $page_node->nid == $node->nid : FALSE);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-59c559741c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/theme_admin_block/7.x | In Drupal 7, write the function `theme_admin_block($variables)` (file modules/system/system.admin.inc) so that it does the following: Returns HTML for an administrative block for display. | Parameters:
- $variables: An associative array containing: - block: An array containing information about the block: - show: A Boolean whether to output the block. Defaults to FALSE. - title: The block's title. - content: (optional) Formatted content for the block. - description: (optional) Description of the block. On... | function theme_admin_block($variables) {
$block = $variables['block'];
$output = '';
// Don't display the block if it has no content to display.
if (empty($block['show'])) {
return $output;
}
$output .= '<div class="admin-panel">';
if (!empty($block['title'])) {
$output .= '<h3>' . $block['title... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-59d08d40c1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_field_update_instance/7.x | I need the code for `image_field_update_instance($instance, $prior_instance)` in Drupal 7 (modules/image/image.module). It must do this: Implements hook_field_update_instance(). | File: modules/image/image.module | function image_field_update_instance($instance, $prior_instance) {
// Only act on image fields.
$field = field_read_field($instance['field_name']);
if ($field['type'] != 'image') {
return;
}
// The value of a managed_file element can be an array if the #extended
// property is set to TRUE.
$fid_new =... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-59ea4e96c1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_add_link_labels/7.x | Implement `menu_add_link_labels(&$title, $item)` in PHP for Drupal 7. Required behavior: Adds labels to the title of a hidden, unpublished or logged-in menu link. | Parameters:
- $title (string): The title of the menu link. This will be modified as necessary to add the appropriate label in parentheses at the end.
- $item (array): An array representing the menu link item.
File: modules/menu/menu.module | function menu_add_link_labels(&$title, $item) {
if ($item['hidden']) {
$title .= ' (' . t('disabled') . ')';
}
elseif (!empty($item['node_unpublished'])) {
$title .= ' (' . t('unpublished') . ')';
}
elseif ($item['link_path'] == 'user' && $item['module'] == 'system') {
$title .= ' (' . t('logged i... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-59f1beb5c3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_form_element/7.x | Implement `theme_form_element($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a form element. | Each form element is wrapped in a DIV container having the following CSS
classes:
- form-item: Generic for all form elements.
- form-type-#type: The internal element #type.
- form-item-#name: The internal form element #name (usually derived from the
$form structure and set via form_builder()).
- form-disabled: Only s... | function theme_form_element($variables) {
$element = &$variables['element'];
// This function is invoked as theme wrapper, but the rendered form element
// may not necessarily have been processed by form_builder().
$element += array(
'#title_display' => 'before',
);
// Add element #id for #type 'item'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5a143dbb57 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21session.inc/function/drupal_session_id/7.x | I need the code for `drupal_session_id($id)` in Drupal 7 (includes/session.inc). It must do this: Session ids are hashed by default before being stored in the database. | This should only be done if any existing sessions have been updated, as reflected by the hash_session_ids variable.
Parameters:
- $id: A session id.
Returns: The session id which may have been hashed.
File: includes/session.inc | function drupal_session_id($id) {
if (variable_get('hashed_session_ids_supported', FALSE) && !variable_get('do_not_hash_session_ids', FALSE)) {
$id = drupal_hash_base64($id);
}
return $id;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5a2b4dd7bc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_search_execute/7.x | Implement `user_search_execute($keys = NULL, $conditions = NULL)` in PHP for Drupal 7. Required behavior: Implements hook_search_execute(). | File: modules/user/user.module | function user_search_execute($keys = NULL, $conditions = NULL) {
$find = array();
// Escape for LIKE matching.
$keys = db_like($keys);
// Replace wildcards with MySQL/PostgreSQL wildcards.
$keys = preg_replace('!\*+!', '%', $keys);
$query = db_select('users')->extend('PagerDefault');
$query->fields('users... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-5a3044e9a2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_file_download/7.x | Implement `system_file_download($uri)` in PHP for Drupal 7. Required behavior: Implements hook_file_download(). | File: modules/system/system.module | function system_file_download($uri) {
$scheme = file_uri_scheme($uri);
if (file_stream_wrapper_valid_scheme($scheme)) {
$target = file_uri_target($uri);
if ($target !== FALSE) {
if (!in_array($scheme, variable_get('file_sa_core_2023_005_schemes', array()))) {
if (DIRECTORY_SEPARATOR !== '/') {... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-5a307bfc6f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_view_field/7.x | Implement `field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL)` in PHP for Drupal 7. Required behavior: Returns a renderable array for the value of a single field in an entity. | The resulting output is a fully themed field with label and multiple values.
This function can be used by third-party modules that need to output an
isolated field.
- Do not use inside node (or any other entity) templates; use
render($content[FIELD_NAME]) instead.
- Do not use to display all fields in an entity; use... | function field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL) {
$output = array();
if ($field = field_info_field($field_name)) {
if (is_array($display)) {
// When using custom display settings, fill in default values.
$cache = _field_info_field_cache();
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5a43cc8f74 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_modules_installed/7.x | Implement `user_modules_installed($modules)` in PHP for Drupal 7. Required behavior: Implements hook_modules_installed(). | File: modules/user/user.module | function user_modules_installed($modules) {
// Assign all available permissions to the administrator role.
$rid = variable_get('user_admin_role', 0);
if ($rid) {
$permissions = array();
foreach ($modules as $module) {
if ($module_permissions = module_invoke($module, 'permission')) {
$permiss... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-5a635342c8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/update.php/function/update_selection_page/7.x | I need the code for `update_selection_page()` in Drupal 7 (update.php). It must do this: Renders a form with a list of available database updates. | File: update.php | function update_selection_page() {
drupal_set_title('Drupal database update');
$elements = drupal_get_form('update_script_selection_form');
$output = drupal_render($elements);
update_task_list('select');
return $output;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5a7c4f2268 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.admin.inc/function/search_admin_settings_submit/7.x | In Drupal 7, write the function `search_admin_settings_submit($form, &$form_state)` (file modules/search/search.admin.inc) so that it does the following: Form submission handler for search_admin_settings(). | File: modules/search/search.admin.inc | function search_admin_settings_submit($form, &$form_state) {
// If these settings change, the index needs to be rebuilt.
if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) ||
(variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) {
drupal_set_mes... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5a80c0e05a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_add_module_assets/7.x | Implement `system_add_module_assets()` in PHP for Drupal 7. Required behavior: Adds CSS and JavaScript files declared in module .info files. | File: modules/system/system.module | function system_add_module_assets() {
foreach (system_get_info('module') as $module => $info) {
if (!empty($info['stylesheets'])) {
foreach ($info['stylesheets'] as $media => $stylesheets) {
foreach ($stylesheets as $stylesheet) {
drupal_add_css($stylesheet, array('every_page' => TRUE, 'me... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5a83e9169f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_math_cmp/7.x | Implement `_openid_math_cmp($x, $y)` in PHP for Drupal 7. Required behavior: Calls the cmp function from the available math library for OpenID. | File: modules/openid/openid.inc | function _openid_math_cmp($x, $y) {
$library = _openid_get_math_library();
switch ($library) {
case 'gmp':
return gmp_cmp($x, $y);
case 'bcmath':
return bccomp($x, $y);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5a9b2f6339 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/_system_sort_requirements/7.x | Implement `_system_sort_requirements($a, $b)` in PHP for Drupal 7. Required behavior: Helper function to sort requirements. | File: modules/system/system.module | function _system_sort_requirements($a, $b) {
if (!isset($a['weight'])) {
if (!isset($b['weight'])) {
return strcasecmp($a['title'], $b['title']);
}
return -$b['weight'];
}
return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5ab0e6de73 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7027/7.x | I need the code for `system_update_7027()` in Drupal 7 (modules/system/system.install). It must do this: Enable field type modules. | File: modules/system/system.install | function system_update_7027() {
$module_list = array('text', 'number', 'list', 'options');
module_enable($module_list, FALSE);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5ac103e877 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.form.inc/function/field_default_form/7.x | In Drupal 7, write the function `field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL)` (file modules/field/field.form.inc) so that it does the following: Creates a form element for a field and can populate it with a default value. | If the form element is not associated with an entity (i.e., $entity is NULL) field_get_default_value will be called to supply the default value for the field. Also allows other modules to alter the form element by implementing their own hooks.
Parameters:
- $entity_type: The type of entity (for example 'node' or 'user... | function field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) {
// This could be called with no entity, as when a UI module creates a
// dummy form to set default values.
if ($entity) {
list($id, , ) = entity_extract_ids($entity_type, $entity... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5ace23094d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_storage_pre_insert/7.x | Give me the example code for `hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields)` in Drupal 7. Hook description: Act before the storage backends insert field data. | This hook allows modules to store data before the Field Storage API, optionally preventing the field storage module from doing so.
Parameters:
- $entity_type: The type of $entity; for example, 'node' or 'user'.
- $entity: The entity with fields to save.
- $skip_fields: An array keyed by field IDs whose data has alread... | function hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
$query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
forea... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-5ad0ed6e76 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/options_field_widget_info/7.x | Implement `options_field_widget_info()` in PHP for Drupal 7. Required behavior: Implements hook_field_widget_info(). | Field type modules willing to use those widgets should:
- Use hook_field_widget_info_alter() to append their field own types to the
list of types supported by the widgets,
- Implement hook_options_list() to provide the list of options.
See list.module.
File: modules/field/modules/options/options.module | function options_field_widget_info() {
return array(
'options_select' => array(
'label' => t('Select list'),
'field types' => array(),
'behaviors' => array(
'multiple values' => FIELD_BEHAVIOR_CUSTOM,
),
),
'options_buttons' => array(
'label' => t('Check boxes/radio b... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-5ad9f4a72a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.maintenance.inc/function/_drupal_maintenance_theme/7.x | Implement `_drupal_maintenance_theme()` in PHP for Drupal 7. Required behavior: Sets up the theming system for maintenance page. | Used for site installs, updates and when the site is in maintenance mode. It also applies when the database is unavailable or bootstrap was not complete. Seven is always used for the initial install and update operations. In other cases, Bartik is used, but this can be overridden by setting a "maintenance_theme" key in... | function _drupal_maintenance_theme() {
global $theme, $theme_key, $conf;
// If $theme is already set, assume the others are set too, and do nothing.
if (isset($theme)) {
return;
}
require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
require_once DRUPAL_ROOT . '/includes/them... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5afd4363e6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_dom_serialize/7.x | In Drupal 7, write the function `filter_dom_serialize($dom_document)` (file modules/filter/filter.module) so that it does the following: Converts a DOM object back to an HTML snippet. | The function serializes the body part of a DOMDocument back to an XHTML snippet. The resulting XHTML snippet will be properly formatted to be compatible with HTML user agents.
Parameters:
- $dom_document: A DOMDocument object to serialize, only the tags below the first <body> node will be converted.
Returns: A valid ... | function filter_dom_serialize($dom_document) {
$body_node = $dom_document->getElementsByTagName('body')->item(0);
$body_content = '';
if ($body_node !== NULL) {
foreach ($body_node->getElementsByTagName('script') as $node) {
filter_dom_serialize_escape_cdata_element($dom_document, $node);
}
fo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5b060699c1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_language_selector_form/7.x | I need the code for `locale_language_selector_form(&$form, &$form_state, $user)` in Drupal 7 (modules/locale/locale.module). It must do this: Form builder callback to display language selection widget. | File: modules/locale/locale.module | function locale_language_selector_form(&$form, &$form_state, $user) {
global $language;
$languages = language_list('enabled');
$languages = $languages[1];
// If the user is being created, we set the user language to the page language.
$user_preferred_language = $user->uid ? user_preferred_language($user) : $... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5b097d8854 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_date_format_locale/7.x | I need the code for `system_date_format_locale($langcode = NULL, $type = NULL)` in Drupal 7 (modules/system/system.module). It must do this: Gets the appropriate date format string for a date type and locale. | Parameters:
- $langcode: (optional) Language code for the current locale. This can be a 2 character language code like 'en' and 'fr' or a 5 character language code like 'en-gb' and 'en-us'.
- $type: (optional) The date type name.
Returns: If $type and $langcode are specified, returns the corresponding date format stri... | function system_date_format_locale($langcode = NULL, $type = NULL) {
$formats = &drupal_static(__FUNCTION__);
if (empty($formats)) {
$formats = array();
$result = db_query("SELECT format, type, language FROM {date_format_locale}");
foreach ($result as $record) {
if (!isset($formats[$record->langu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5b0f1b3202 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_toolbar_pre_render/7.x | I need the code for `shortcut_toolbar_pre_render($toolbar)` in Drupal 7 (modules/shortcut/shortcut.module). It must do this: Pre-render function for adding shortcuts to the toolbar drawer. | File: modules/shortcut/shortcut.module | function shortcut_toolbar_pre_render($toolbar) {
$links = shortcut_renderable_links();
$links['#attached'] = array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css'));
$links['#prefix'] = '<div class="toolbar-shortcuts">';
$links['#suffix'] = '</div>';
$shortcut_set = shortcut_current_dis... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5b6297e8b3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_invoke/7.x | I need the code for `node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL)` in Drupal 7 (modules/node/node.module). It must do this: Invokes a node hook. | Parameters:
- $node: A node object or a string containing the node type.
- $hook: A string containing the name of the hook.
- $a3 ($a2,): , $a4 Arguments to pass on to the hook, after the $node argument.
Returns: The returned value of the invoked hook.
File: modules/node/node.module | function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
if (node_hook($node, $hook)) {
$base = node_type_get_base($node);
$function = $base . '_' . $hook;
return ($function($node, $a2, $a3, $a4));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5b9a89d36e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpc.inc/function/xmlrpc_message_cdata/7.x | In Drupal 7, write the function `xmlrpc_message_cdata($parser, $cdata)` (file includes/xmlrpc.inc) so that it does the following: Handles character data for XML parsing in xmlrpc_message_parse(). | File: includes/xmlrpc.inc | function xmlrpc_message_cdata($parser, $cdata) {
$xmlrpc_message = xmlrpc_message_get();
$xmlrpc_message->current_tag_contents .= $cdata;
xmlrpc_message_set($xmlrpc_message);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-5b9eed7c11 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.parser.inc/function/aggregator_aggregator_parse/7.x | I need the code for `aggregator_aggregator_parse($feed)` in Drupal 7 (modules/aggregator/aggregator.parser.inc). It must do this: Implements hook_aggregator_parse(). | File: modules/aggregator/aggregator.parser.inc | function aggregator_aggregator_parse($feed) {
global $channel, $image;
// Filter the input data.
if (aggregator_parse_feed($feed->source_string, $feed)) {
$modified = empty($feed->http_headers['last-modified']) ? 0 : strtotime($feed->http_headers['last-modified']);
// Prepare the channel data.
forea... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.