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-fb5e9e7dee | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_verify_install_file/7.x | In Drupal 7, write the function `drupal_verify_install_file($file, $mask = NULL, $type = 'file', $autofix = TRUE)` (file includes/install.inc) so that it does the following: Verifies the state of the specified file. | Parameters:
- $file: The file to check for.
- $mask: An optional bitmask created from various FILE_* constants.
- $type: The type of file. Can be file (default), dir, or link.
- $autofix (bool): (optional) Determines whether to attempt fixing the permissions according to the provided $mask. Defaults to TRUE.
Returns: ... | function drupal_verify_install_file($file, $mask = NULL, $type = 'file', $autofix = TRUE) {
$return = TRUE;
// Check for files that shouldn't be there.
if (isset($mask) && ($mask & FILE_NOT_EXIST) && file_exists($file)) {
return FALSE;
}
// Verify that the file is the type of file it is supposed to be.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fb66edab1f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.admin.inc/function/aggregator_admin_remove_feed_submit/7.x | In Drupal 7, write the function `aggregator_admin_remove_feed_submit($form, &$form_state)` (file modules/aggregator/aggregator.admin.inc) so that it does the following: Form submission handler for aggregator_admin_remove_feed(). | Removes all items from a feed and redirects to the overview page.
File: modules/aggregator/aggregator.admin.inc | function aggregator_admin_remove_feed_submit($form, &$form_state) {
aggregator_remove($form_state['values']['feed']);
$form_state['redirect'] = 'admin/config/services/aggregator';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fb6d6d1a0f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_date_format_types/7.x | Implement `system_date_format_types()` in PHP for Drupal 7. Required behavior: Implements hook_date_format_types(). | File: modules/system/system.module | function system_date_format_types() {
return array(
'long' => t('Long'),
'medium' => t('Medium'),
'short' => t('Short'),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fb85f816a4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.pages.inc/function/comment_reply/7.x | In Drupal 7, write the function `comment_reply($node, $pid = NULL)` (file modules/comment/comment.pages.inc) so that it does the following: This function is responsible for generating a comment reply form. There are several cases that have to be handled, including: - replies to comments - replies to nodes - attempts to... | The node or comment that is being replied to must appear above the comment form to provide the user context while authoring the comment.
Parameters:
- $node: Every comment belongs to a node. This is that node.
- $pid: Some comments are replies to other comments. In those cases, $pid is the parent comment's cid.
Retur... | function comment_reply($node, $pid = NULL) {
// Set the breadcrumb trail.
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
$op = isset($_POST['op']) ? $_POST['op'] : '';
$build = array();
// The user is previewing a comment prior to submitting it.
if ($op == t('Previ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fb93d40587 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_comment_update/7.x | Implement `forum_comment_update($comment)` in PHP for Drupal 7. Required behavior: Implements hook_comment_update(). | The Comment module doesn't call hook_comment_unpublish() when saving individual comments, so we need to check for those here.
File: modules/forum/forum.module | function forum_comment_update($comment) {
// comment_save() calls hook_comment_publish() for all published comments,
// so we need to handle all other values here.
if (!$comment->status) {
_forum_update_forum_index($comment->nid);
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fbaa43228f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_validate/7.x | I need the code for `field_attach_validate($entity_type, $entity, $options = array())` in Drupal 7 (modules/field/field.attach.inc). It must do this: Perform field validation against the field data in an entity. | This function does not perform field widget validation on form submissions. It is intended to be called during API save operations. Use field_attach_form_validate() to validate form submissions.
Parameters:
- $entity_type: The type of $entity; e.g. 'node' or 'user'.
- $entity: The entity with fields to validate.
- $op... | function field_attach_validate($entity_type, $entity, $options = array()) {
// Validate $options since this is a new parameter added after Drupal 7 was
// released.
$options = is_array($options) ? $options : array();
$errors = array();
// Check generic, field-type-agnostic errors first.
$null = NULL;
_fi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fbe131d04b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_term_confirm_delete/7.x | I need the code for `taxonomy_term_confirm_delete($form, &$form_state, $tid)` in Drupal 7 (modules/taxonomy/taxonomy.admin.inc). It must do this: Form builder for the term delete form. | File: modules/taxonomy/taxonomy.admin.inc | function taxonomy_term_confirm_delete($form, &$form_state, $tid) {
$term = taxonomy_term_load($tid);
// Always provide entity id in the same form key as in the entity edit form.
$form['tid'] = array('#type' => 'value', '#value' => $tid);
$form['#term'] = $term;
$form['type'] = array('#type' => 'value', '#va... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fbe4914a16 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_export_po_generate/7.x | Implement `_locale_export_po_generate($language = NULL, $strings = array(), $header = NULL)` in PHP for Drupal 7. Required behavior: Generates the PO(T) file contents for given strings. | Parameters:
- $language: Language object to generate the output for, or NULL if generating translation template.
- $strings: Array of strings to export. See _locale_export_get_strings() on how it should be formatted.
- $header: The header portion to use for the output file. Defaults are provided for PO and POT files.
... | function _locale_export_po_generate($language = NULL, $strings = array(), $header = NULL) {
global $user;
if (!isset($header)) {
if (isset($language)) {
$header = '# ' . $language->name . ' translation of ' . variable_get('site_name', 'Drupal') . "\n";
$header .= '# Generated by ' . $user->name . '... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fbfc565e1e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.install/function/list_field_schema/7.x | In Drupal 7, write the function `list_field_schema($field)` (file modules/field/modules/list/list.install) so that it does the following: Implements hook_field_schema(). | File: modules/field/modules/list/list.install | function list_field_schema($field) {
switch ($field['type']) {
case 'list_text':
$columns = array(
'value' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
);
break;
case 'list_float':
$columns = array(
'value... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fbfcd5855c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_cancel_confirm_form/7.x | In Drupal 7, write the function `user_cancel_confirm_form($form, &$form_state, $account)` (file modules/user/user.pages.inc) so that it does the following: Form builder; confirm form for cancelling user account. | File: modules/user/user.pages.inc | function user_cancel_confirm_form($form, &$form_state, $account) {
global $user;
$form['_account'] = array('#type' => 'value', '#value' => $account);
// Display account cancellation method selection, if allowed.
$admin_access = user_access('administer users');
$can_select_method = $admin_access || user_acce... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc0a0cce31 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_configure/7.x | I need the code for `menu_configure()` in Drupal 7 (modules/menu/menu.admin.inc). It must do this: Menu callback; Build the form presenting menu configuration options. | File: modules/menu/menu.admin.inc | function menu_configure() {
$form['intro'] = array(
'#type' => 'item',
'#markup' => t('The menu module allows on-the-fly creation of menu links in the content authoring forms. To configure these settings for a particular content type, visit the <a href="@content-types">Content types</a> page, click the <em>ed... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc3af7c1e7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_translate_language_list/7.x | I need the code for `_locale_translate_language_list($string, $limit_language)` in Drupal 7 (includes/locale.inc). It must do this: List languages in search result table | File: includes/locale.inc | function _locale_translate_language_list($string, $limit_language) {
// Add CSS.
drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
// Include both translated and not yet translated target languages in the
// list. The source language is English for built-in strings and the default
// langu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc3fbafd28 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/template_preprocess_maintenance_page/7.x | Implement `template_preprocess_maintenance_page(&$variables)` in PHP for Drupal 7. Required behavior: Process variables for maintenance-page.tpl.php. | The variables array generated here is a mirror of template_preprocess_page(). This preprocessor will run its course when theme_maintenance_page() is invoked. An alternate template file of maintenance-page--offline.tpl.php can be used when the database is offline to hide errors and completely replace the content.
The $... | function template_preprocess_maintenance_page(&$variables) {
// Add favicon
if (theme_get_setting('toggle_favicon')) {
$favicon = theme_get_setting('favicon');
$type = theme_get_setting('favicon_mimetype');
drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protoc... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc4df622b1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_type_get_base/7.x | I need the code for `node_type_get_base($node)` in Drupal 7 (modules/node/node.module). It must do this: Returns the node type base of the passed node or node type string. | The base indicates which module implements this node type and is used to execute node-type-specific hooks. For types defined in the user interface and managed by node.module, the base is 'node_content'.
Parameters:
- $node: A node object or string that indicates the node type to return.
Returns: The node type base or... | function node_type_get_base($node) {
$type = _node_extract_type($node);
$types = _node_types_build()->types;
return isset($types[$type]) && isset($types[$type]->base) ? $types[$type]->base : FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc52bb5ef4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.settings.inc/function/update_settings_submit/7.x | I need the code for `update_settings_submit($form, $form_state)` in Drupal 7 (modules/update/update.settings.inc). It must do this: Form submission handler for update_settings(). | Also invalidates the cache of available updates if the "Check for updates of disabled and uninstalled modules and themes" setting is being changed. The available updates report needs to refetch available update data after this setting changes or it would show misleading things (e.g., listing the disabled projects on th... | function update_settings_submit($form, $form_state) {
$op = $form_state['values']['op'];
if (empty($form_state['notify_emails'])) {
variable_del('update_notify_emails');
}
else {
variable_set('update_notify_emails', $form_state['notify_emails']);
}
unset($form_state['notify_emails']);
unset($form... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc57f4228a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_user_operations/7.x | In Drupal 7, write the function `user_user_operations($form = array(), $form_state = array())` (file modules/user/user.module) so that it does the following: Implements hook_user_operations(). | File: modules/user/user.module | function user_user_operations($form = array(), $form_state = array()) {
$operations = array(
'unblock' => array(
'label' => t('Unblock the selected users'),
'callback' => 'user_user_operations_unblock',
),
'block' => array(
'label' => t('Block the selected users'),
'callback' => 'u... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fc6bac7a85 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7.x | Give me the example code for `hook_form_alter(&$form, &$form_state, $form_id)` in Drupal 7. Hook description: Perform alterations before a form is rendered. | One popular use of this hook is to add form elements to the node form. When altering a node form, the node object can be accessed at $form['#node'].
In addition to hook_form_alter(), which is called for all forms, there are two more specific form hooks available. The first, hook_form_BASE_FORM_ID_alter(), allows targe... | function hook_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
$form['workflow']['upload_' . $form['type']['#value']] = array(
'#type' => 'radios',
'#title' => t('Attachments'),
'#default_value' => variable_get('up... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-fc6ffa005b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_view/7.x | I need the code for `user_view($account, $view_mode = 'full', $langcode = NULL)` in Drupal 7 (modules/user/user.module). It must do this: Generate an array for rendering the given user. | When viewing a user profile, the $page array contains:
- $page['content']['Profile Category']:
Profile categories keyed by their human-readable names.
- $page['content']['Profile Category']['profile_machine_name']:
Profile fields keyed by their machine-readable names.
- $page['content']['user_picture']:
User's r... | function user_view($account, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Retrieve all profile fields and attach to $account->content.
user_build_content($account, $view_mode, $langcode);
$build = $account->content;
// We do... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc70869d13 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.admin.inc/function/template_preprocess_block_admin_display_form/7.x | In Drupal 7, write the function `template_preprocess_block_admin_display_form(&$variables)` (file modules/block/block.admin.inc) so that it does the following: Processes variables for block-admin-display-form.tpl.php. | The $variables array contains the following arguments:
- $form
File: modules/block/block.admin.inc | function template_preprocess_block_admin_display_form(&$variables) {
$variables['block_regions'] = $variables['form']['block_regions']['#value'];
if (isset($variables['block_regions'][BLOCK_REGION_NONE])) {
$variables['block_regions'][BLOCK_REGION_NONE] = t('Disabled');
}
foreach ($variables['block_regions... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fc7c1aeeca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.admin.inc/function/statistics_recent_hits/7.x | Implement `statistics_recent_hits()` in PHP for Drupal 7. Required behavior: Page callback: Displays the "recent hits" page. | This displays the pages with recent hits in a given time interval that haven't been flushed yet. The flush interval is set on the statistics settings form, but is dependent on cron running.
Returns: A render array containing information about the most recent hits.
File: modules/statistics/statistics.admin.inc | function statistics_recent_hits() {
$header = array(
array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'),
array('data' => t('Page'), 'field' => 'a.path'),
array('data' => t('User'), 'field' => 'u.name'),
array('data' => t('Operations'))
);
$query = db_select('accesslog', '... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fca3e43ed4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_bootstrap_page_header/7.x | I need the code for `_drupal_bootstrap_page_header()` in Drupal 7 (includes/bootstrap.inc). It must do this: Invokes hook_boot(), initializes locking system, and sends HTTP headers. | File: includes/bootstrap.inc | function _drupal_bootstrap_page_header() {
bootstrap_invoke_all('boot');
if (!drupal_is_cli()) {
ob_start();
drupal_page_header();
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fca5955ce9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.authorize.inc/function/update_authorize_update_batch_finished/7.x | Implement `update_authorize_update_batch_finished($success, $results)` in PHP for Drupal 7. Required behavior: Implements callback_batch_finished(). | Performs actions when the authorized update batch is done.
This processes the results and stashes them into SESSION such that authorize.php will render a report. Also responsible for putting the site back online and clearing the update status cache after a successful update.
Parameters:
- $success: TRUE if the batch ... | function update_authorize_update_batch_finished($success, $results) {
foreach ($results['log'] as $project => $messages) {
if (!empty($messages['#abort'])) {
$success = FALSE;
}
}
$offline = variable_get('maintenance_mode', FALSE);
if ($success) {
// Now that the update completed, we need to c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fcc8ef9d92 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_cancel/7.x | In Drupal 7, write the function `user_cancel($edit, $uid, $method)` (file modules/user/user.module) so that it does the following: Cancel a user account. | Since the user cancellation process needs to be run in a batch, either Form API will invoke it, or batch_process() needs to be invoked after calling this function and should define the path to redirect to.
Parameters:
- $edit: An array of submitted form values.
- $uid: The user ID of the user account to cancel.
- $met... | function user_cancel($edit, $uid, $method) {
global $user;
$account = user_load($uid);
if (!$account) {
drupal_set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error');
watchdog('user', 'Attempted to cancel non-existing user account: %id.', array('%id' => $uid), WATCHDOG_ERR... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fcd03fd61a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_update/7.x | Give me the example code for `hook_node_update($node)` in Drupal 7. Hook description: Respond to updates to a node. | This hook is invoked from node_save() after the database query that will update node in the node table is scheduled for execution, after the type-specific hook_update() is invoked, and after field_attach_update() is called.
Note that when this hook is invoked, the changes have not yet been written to the database, bec... | function hook_node_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-fcdb591e0d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_delete/7.x | Implement `file_delete(stdClass $file, $force = FALSE)` in PHP for Drupal 7. Required behavior: Deletes a file and its database record. | If the $force parameter is not TRUE, file_usage_list() will be called to determine if the file is being used by any modules. If the file is being used the delete will be canceled.
Parameters:
- $file: A file object.
- $force: Boolean indicating that the file should be deleted even if the file is reported as in use by ... | function file_delete(stdClass $file, $force = FALSE) {
if (!file_valid_uri($file->uri)) {
if (($realpath = drupal_realpath($file->uri)) !== FALSE) {
watchdog('file', 'File %file (%realpath) could not be deleted because it is not a valid URI. This may be caused by improper use of file_delete() or a missing s... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fce44ab97d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_theme/7.x | I need the code for `comment_theme()` in Drupal 7 (modules/comment/comment.module). It must do this: Implements hook_theme(). | File: modules/comment/comment.module | function comment_theme() {
return array(
'comment_block' => array(
'variables' => array(),
),
'comment_preview' => array(
'variables' => array('comment' => NULL),
),
'comment' => array(
'template' => 'comment',
'render element' => 'elements',
),
'comment_post_forbid... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fceb32c5fe | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_modules_uninstall_validate/7.x | Implement `system_modules_uninstall_validate($form, &$form_state)` in PHP for Drupal 7. Required behavior: Validates the submitted uninstall form. | File: modules/system/system.admin.inc | function system_modules_uninstall_validate($form, &$form_state) {
// Form submitted, but no modules selected.
if (!count(array_filter($form_state['values']['uninstall']))) {
drupal_set_message(t('No modules selected.'), 'error');
drupal_goto('admin/modules/uninstall');
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fd17687d9d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_password/7.x | Implement `user_password($length = 10)` in PHP for Drupal 7. Required behavior: Generate a random alphanumeric password. | File: modules/user/user.module | function user_password($length = 10) {
// This variable contains the list of allowable characters for the
// password. Note that the number 0 and the letter 'O' have been
// removed to avoid confusion between the two. The same is true
// of 'I', 1, and 'l'.
$allowable_characters = 'abcdefghijkmnopqrstuvwxyzAB... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fd76aa3dba | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_module_invoke/7.x | I need the code for `user_module_invoke($type, &$edit, $account, $category = NULL)` in Drupal 7 (modules/user/user.module). It must do this: Invokes a user hook in every module. | We cannot use module_invoke() for this, because the arguments need to be passed by reference.
Parameters:
- $type: A text string that controls which user hook to invoke. Valid choices are: - cancel: Invokes hook_user_cancel(). - insert: Invokes hook_user_insert(). - login: Invokes hook_user_login(). - presave: Invokes... | function user_module_invoke($type, &$edit, $account, $category = NULL) {
foreach (module_implements('user_' . $type) as $module) {
$function = $module . '_user_' . $type;
$function($edit, $account, $category);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fd880bc79c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/template_preprocess_book_all_books_block/7.x | In Drupal 7, write the function `template_preprocess_book_all_books_block(&$variables)` (file modules/book/book.module) so that it does the following: Processes variables for book-all-books-block.tpl.php. | All non-renderable elements are removed so that the template has full access to the structured data but can also simply iterate over all elements and render them (as in the default template).
Parameters:
- $variables: An associative array containing the following key: - book_menus
File: modules/book/book.module | function template_preprocess_book_all_books_block(&$variables) {
// Remove all non-renderable elements.
$elements = $variables['book_menus'];
$variables['book_menus'] = array();
foreach (element_children($elements) as $index) {
$variables['book_menus'][$index] = $elements[$index];
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fd88f0d5bc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.manager.inc/function/update_manager_install_form/7.x | I need the code for `update_manager_install_form($form, &$form_state, $context)` in Drupal 7 (modules/update/update.manager.inc). It must do this: Form constructor for the install form of the Update Manager module. | This presents a place to enter a URL or upload an archive file to use to install a new module or theme.
Parameters:
- $context: String representing the context from which we're trying to install. Allowed values are 'module', 'theme', and 'report'.
File: modules/update/update.manager.inc | function update_manager_install_form($form, &$form_state, $context) {
if (!_update_manager_check_backends($form, 'install')) {
return $form;
}
$form['help_text'] = array(
'#prefix' => '<p>',
'#markup' => t('You can find <a href="@module_url">modules</a> and <a href="@theme_url">themes</a> on <a href=... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fdcfedbcdf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7009/7.x | I need the code for `system_update_7009()` in Drupal 7 (modules/system/system.install). It must do this: Rename the variable for primary links. | File: modules/system/system.install | function system_update_7009() {
$current_primary = variable_get('menu_primary_links_source');
if (isset($current_primary)) {
variable_set('menu_main_links_source', $current_primary);
variable_del('menu_primary_links_source');
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fe1d8746eb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21actions.inc/function/actions_do/7.x | In Drupal 7, write the function `actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a2 = NULL)` (file includes/actions.inc) so that it does the following: Performs a given list of actions by executing their callback functions. | Given the IDs of actions to perform, this function finds out what the callback functions for the actions are by querying the database. Then it calls each callback using the function call $function($object, $context, $a1, $a2), passing the input arguments of this function (see below) to the action function.
Parameters:... | function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a2 = NULL) {
// $stack tracks the number of recursive calls.
static $stack;
$stack++;
if ($stack > variable_get('actions_max_stack', 35)) {
watchdog('actions', 'Stack overflow: too many calls to actions_do(). Aborting to prevent ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fe22bc1b54 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21session.inc/function/drupal_session_start/7.x | I need the code for `drupal_session_start()` in Drupal 7 (includes/session.inc). It must do this: Starts a session forcefully, preserving already set session data. | File: includes/session.inc | function drupal_session_start() {
// Command line clients do not support cookies nor sessions.
if (!drupal_session_started() && !drupal_is_cli()) {
// Save current session data before starting it, as PHP will destroy it.
$session_data = isset($_SESSION) ? $_SESSION : NULL;
// Apply any overrides to the... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fe52269b60 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.module/function/path_node_delete/7.x | Implement `path_node_delete($node)` in PHP for Drupal 7. Required behavior: Implements hook_node_delete(). | File: modules/path/path.module | function path_node_delete($node) {
// Delete all aliases associated with this node.
path_delete(array('source' => 'node/' . $node->nid));
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fe73bae9b3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_actions_delete_form_submit/7.x | Implement `system_actions_delete_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Process system_actions_delete form submissions. | Post-deletion operations for action deletion.
File: modules/system/system.admin.inc | function system_actions_delete_form_submit($form, &$form_state) {
$aid = $form_state['values']['aid'];
$action = actions_load($aid);
actions_delete($aid);
watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $action->label));
drupal_set_message(t('Action %action was deleted', a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fe764a1e5c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_set_installed_schema_version/7.x | Implement `drupal_set_installed_schema_version($module, $version)` in PHP for Drupal 7. Required behavior: Update the installed version information for a module. | Parameters:
- $module: A module name.
- $version: The new schema version.
File: includes/install.inc | function drupal_set_installed_schema_version($module, $version) {
db_update('system')
->fields(array('schema_version' => $version))
->condition('name', $module)
->execute();
// Reset the static cache of module schema versions.
drupal_get_installed_schema_version(NULL, TRUE);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fe79068425 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_associate_fields/7.x | In Drupal 7, write the function `field_associate_fields($module)` (file modules/field/field.module) so that it does the following: Allows a module to update the database for fields and columns it controls. | Parameters:
- $module: The name of the module to update on.
File: modules/field/field.module | function field_associate_fields($module) {
// Associate field types.
$field_types = (array) module_invoke($module, 'field_info');
if ($field_types) {
db_update('field_config')
->fields(array('module' => $module, 'active' => 1))
->condition('type', array_keys($field_types))
->execute();
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fe9ddf7bf0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/theme_dashboard_region/7.x | In Drupal 7, write the function `theme_dashboard_region($variables)` (file modules/dashboard/dashboard.module) so that it does the following: Returns HTML for a generic dashboard region. | Parameters:
- $variables: An associative array containing: - element: A render element containing the properties of the dashboard region element, #dashboard_region and #children.
File: modules/dashboard/dashboard.module | function theme_dashboard_region($variables) {
extract($variables);
$output = '<div id="' . $element['#dashboard_region'] . '" class="dashboard-region">';
$output .= '<div class="region clearfix">';
$output .= $element['#children'];
// Closing div.region
$output .= '</div>';
// Closing div.dashboard-region... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fe9dec3330 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_menu/7.x | I need the code for `update_menu()` in Drupal 7 (modules/update/update.module). It must do this: Implements hook_menu(). | File: modules/update/update.module | function update_menu() {
$items = array();
$items['admin/reports/updates'] = array(
'title' => 'Available updates',
'description' => 'Get a status report about available updates for your installed modules and themes.',
'page callback' => 'update_status',
'access arguments' => array('administer site... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fea58645df | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21announcements_feed%21announcements_feed.inc/function/announcements_feed_filter_announcements/7.x | I need the code for `announcements_feed_filter_announcements($announcement)` in Drupal 7 (modules/announcements_feed/announcements_feed.inc). It must do this: Filter the announcements relevant to the Drupal version used with valid URL controlled by drupal.org. | Parameters:
- $announcement (array): Announcement feed array item to check.
Returns (bool): Return TRUE if $announcement is relevant and the URL is valid.
File: modules/announcements_feed/announcements_feed.inc | function announcements_feed_filter_announcements($announcement) {
$announcement_url = '';
$announcement_version = '';
if (!empty($announcement['url'])) {
$announcement_url = $announcement['url'];
}
if (!empty($announcement['_drupalorg']['version'])) {
$announcement_version = $announcement['_drupalorg'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fea917d1a5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_get_schema/7.x | In Drupal 7, write the function `drupal_get_schema($table = NULL, $rebuild = FALSE)` (file includes/bootstrap.inc) so that it does the following: Gets the schema definition of a table, or the whole database schema. | The returned schema will include any modifications made by any module that implements hook_schema_alter(). To get the schema without modifications, use drupal_get_schema_unprocessed().
Parameters:
- $table: The name of the table. If not given, the schema of all tables is returned.
- $rebuild: If true, the schema will ... | function drupal_get_schema($table = NULL, $rebuild = FALSE) {
static $schema;
if ($rebuild || !isset($table)) {
$schema = drupal_get_complete_schema($rebuild);
}
elseif (!isset($schema)) {
$schema = new SchemaCache();
}
if (!isset($table)) {
return $schema;
}
if (isset($schema[$table])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-feaa0e3929 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_theme/7.x | In Drupal 7, write the function `locale_theme()` (file modules/locale/locale.module) so that it does the following: Implements hook_theme(). | File: modules/locale/locale.module | function locale_theme() {
return array(
'locale_languages_overview_form' => array(
'render element' => 'form',
),
'locale_languages_configure_form' => array(
'render element' => 'form',
),
'locale_date_format_form' => array(
'render element' => 'form',
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-feb8b99512 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_admin_paths/7.x | Implement `translation_admin_paths()` in PHP for Drupal 7. Required behavior: Implements hook_admin_paths(). | File: modules/translation/translation.module | function translation_admin_paths() {
if (variable_get('node_admin_theme')) {
$paths = array(
'node/*/translate' => TRUE,
);
return $paths;
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fed09d1c87 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.install/function/shortcut_uninstall/7.x | Implement `shortcut_uninstall()` in PHP for Drupal 7. Required behavior: Implements hook_uninstall(). | File: modules/shortcut/shortcut.install | function shortcut_uninstall() {
drupal_load('module', 'shortcut');
// Delete the menu links associated with each shortcut set.
foreach (shortcut_sets() as $shortcut_set) {
menu_delete_links($shortcut_set->set_name);
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-fee5826462 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/theme_system_admin_index/7.x | In Drupal 7, write the function `theme_system_admin_index($variables)` (file modules/system/system.admin.inc) so that it does the following: Returns HTML for the output of the dashboard page. | Parameters:
- $variables: An associative array containing: - menu_items: An array of modules to be displayed.
File: modules/system/system.admin.inc | function theme_system_admin_index($variables) {
$menu_items = $variables['menu_items'];
$stripe = 0;
$container = array('left' => '', 'right' => '');
$flip = array('left' => 'right', 'right' => 'left');
$position = 'left';
// Iterate over all modules.
foreach ($menu_items as $module => $block) {
lis... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff08cad1ec | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_insert/7.x | I need the code for `ajax_command_insert($selector, $html, $settings = NULL)` in Drupal 7 (includes/ajax.inc). It must do this: Creates a Drupal Ajax 'insert' command using the method in #ajax['method']. | This command instructs the client to insert the given HTML using whichever jQuery DOM manipulation method has been specified in the #ajax['method'] variable of the element that triggered the request.
This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.
Parameters:
- $selecto... | function ajax_command_insert($selector, $html, $settings = NULL) {
return array(
'command' => 'insert',
'method' => NULL,
'selector' => $selector,
'data' => $html,
'settings' => $settings,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff146856bf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_dom_serialize_escape_cdata_element/7.x | I need the code for `filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, $comment_start = '//', $comment_end = '')` in Drupal 7 (modules/filter/filter.module). It must do this: Adds comments around the <!CDATA section in a dom element. | DOMDocument::loadHTML in filter_dom_load() makes CDATA sections from the contents of inline script and style tags. This can cause HTML 4 browsers to throw exceptions.
This function attempts to solve the problem by creating a DocumentFragment and imitating the behavior in drupal_get_js(), commenting the CDATA tag.
Pa... | function filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, $comment_start = '//', $comment_end = '') {
foreach ($dom_element->childNodes as $node) {
if (get_class($node) == 'DOMCdataSection') {
// See drupal_get_js(). This code is more or less duplicated there.
$embed_prefix = "\... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff1586052d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/_drupal_should_strip_sensitive_headers_on_http_redirect/7.x | In Drupal 7, write the function `_drupal_should_strip_sensitive_headers_on_http_redirect($url, $location)` (file includes/common.inc) so that it does the following: Determine whether to strip sensitive headers from a request when redirected. | Parameters:
- $url (string): The url from the original outbound http request.
- $location (string): The location to which the request has been redirected.
Returns (boolean): Whether sensitive headers should be stripped from the request before following the redirect.
File: includes/common.inc | function _drupal_should_strip_sensitive_headers_on_http_redirect($url, $location) {
$url_parsed = parse_url($url);
$location_parsed = parse_url($location);
if (!isset($location_parsed['host'])) {
return FALSE;
}
$strip_on_host_change = variable_get('drupal_http_request_strip_sensitive_headers_on_host_chan... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff1abe860e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.pages.inc/function/search_form_submit/7.x | I need the code for `search_form_submit($form, &$form_state)` in Drupal 7 (modules/search/search.pages.inc). It must do this: Process a search form submission. | File: modules/search/search.pages.inc | function search_form_submit($form, &$form_state) {
$keys = $form_state['values']['processed_keys'];
if ($keys == '') {
form_set_error('keys', t('Please enter some keywords.'));
// Fall through to the form redirect.
}
$form_state['redirect'] = $form_state['action'] . '/' . $keys;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff230241ab | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_theme_select_form_alter/7.x | Implement `_color_theme_select_form_alter(&$form, &$form_state)` in PHP for Drupal 7. Required behavior: Helper for hook_form_FORM_ID_alter() implementations. | File: modules/color/color.module | function _color_theme_select_form_alter(&$form, &$form_state) {
// Use the generated screenshot in the theme list.
$themes = list_themes();
foreach (element_children($form) as $theme) {
if ($screenshot = variable_get('color_' . $theme . '_screenshot')) {
if (isset($form[$theme]['screenshot'])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff232b56b2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_action_info/7.x | Give me the example code for `hook_action_info()` in Drupal 7. Hook description: Declares information about actions. | Any module can define actions, and then call actions_do() to make those actions happen in response to events. The trigger module provides a user interface for associating actions with module-defined triggers, and it makes sure the core triggers fire off actions when their events happen.
An action consists of two or th... | function hook_action_info() {
return array(
'comment_unpublish_action' => array(
'type' => 'comment',
'label' => t('Unpublish comment'),
'configurable' => FALSE,
'behavior' => array('changes_property'),
'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
)... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-ff2e0aa036 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_field_info/7.x | I need the code for `taxonomy_field_info()` in Drupal 7 (modules/taxonomy/taxonomy.module). It must do this: Implements hook_field_info(). | Field settings:
- allowed_values: a list array of one or more vocabulary trees:
- vocabulary: a vocabulary machine name.
- parent: a term ID of a term whose children are allowed. This should be
'0' if all terms in a vocabulary are allowed. The allowed values do not
include the parent term.
File: modules/ta... | function taxonomy_field_info() {
return array(
'taxonomy_term_reference' => array(
'label' => t('Term reference'),
'description' => t('This field stores a reference to a taxonomy term.'),
'default_widget' => 'options_select',
'default_formatter' => 'taxonomy_term_reference_link',
'se... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ff71f33813 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_admin_paths/7.x | Give me the example code for `hook_admin_paths()` in Drupal 7. Hook description: Define administrative paths. | Modules may specify whether or not the paths they define in hook_menu() are to be considered administrative. Other modules may use this information to display those pages differently (e.g. in a modal overlay, or in a different theme).
To change the administrative status of menu items defined in another module's hook_m... | function hook_admin_paths() {
$paths = array(
'mymodule/*/add' => TRUE,
'mymodule/*/edit' => TRUE,
);
return $paths;
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-ff745e65d5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_export_get_strings/7.x | In Drupal 7, write the function `_locale_export_get_strings($language = NULL, $group = 'default')` (file includes/locale.inc) so that it does the following: Generates a structured array of all strings with translations in $language, if given. This array can be used to generate an export of the string in the database. | Parameters:
- $language: Language object to generate the output for, or NULL if generating translation template.
- $group: Text group to export PO file from (eg. 'default' for interface translations).
File: includes/locale.inc | function _locale_export_get_strings($language = NULL, $group = 'default') {
if (isset($language)) {
$result = db_query("SELECT s.lid, s.source, s.context, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.textgroup ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff85f55134 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.mimetypes.inc/function/file_mimetype_mapping/7.x | I need the code for `file_mimetype_mapping()` in Drupal 7 (includes/file.mimetypes.inc). It must do this: Return an array of MIME extension mappings. | Returns the mapping after modules have altered the default mapping.
Returns (Array): of mimetypes correlated to the extensions that relate to them.
File: includes/file.mimetypes.inc | function file_mimetype_mapping() {
$mapping = &drupal_static(__FUNCTION__);
if (!isset($mapping)) {
$mapping = file_default_mimetype_mapping();
// Allow modules to alter the default mapping.
drupal_alter('file_mimetype_mapping', $mapping);
}
return $mapping;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff8cc43900 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_effect_integer_validate/7.x | Implement `image_effect_integer_validate($element, &$form_state)` in PHP for Drupal 7. Required behavior: Element validate handler to ensure an integer pixel value. | The property #allow_negative = TRUE may be set to allow negative integers.
File: modules/image/image.admin.inc | function image_effect_integer_validate($element, &$form_state) {
$value = empty($element['#allow_negative']) ? $element['#value'] : preg_replace('/^-/', '', $element['#value']);
if ($element['#value'] != '' && (!is_numeric($value) || intval($value) <= 0)) {
if (empty($element['#allow_negative'])) {
form_e... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff8f07f579 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/format_string/7.x | In Drupal 7, write the function `format_string($string, array $args = array())` (file includes/bootstrap.inc) so that it does the following: Formats a string for HTML display by replacing variable placeholders. | This function replaces variable placeholders in a string with the requested values and escapes the values so they can be safely displayed as HTML. It should be used on any unknown text that is intended to be printed to an HTML page (especially text that may have come from untrusted users, since in that case it prevents... | function format_string($string, array $args = array()) {
// Transform arguments before inserting them.
foreach ($args as $key => $value) {
switch ($key[0]) {
case '@':
// Escaped only.
$args[$key] = check_plain($value);
break;
case '%':
default:
// Escaped and ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ff9dcaa6b8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.module/function/template_preprocess_profile_block/7.x | I need the code for `template_preprocess_profile_block(&$variables)` in Drupal 7 (modules/profile/profile.module). It must do this: Process variables for profile-block.tpl.php. | The $variables array contains the following arguments:
- $account
- $fields
File: modules/profile/profile.module | function template_preprocess_profile_block(&$variables) {
$variables['user_picture'] = theme('user_picture', array('account' => $variables['account']));
$variables['profile'] = array();
// Supply filtered version of $fields that have values.
foreach ($variables['fields'] as $field) {
if ($field->value) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ffa700373e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.multilingual.inc/function/field_has_translation_handler/7.x | In Drupal 7, write the function `field_has_translation_handler($entity_type, $handler = NULL)` (file modules/field/field.multilingual.inc) so that it does the following: Checks if a module is registered as a translation handler for a given entity. | If no handler is passed, simply check if there is any translation handler enabled for the given entity type.
Parameters:
- $entity_type: The type of the entity whose fields are to be translated.
- $handler: (optional) The name of the handler to be checked. Defaults to NULL.
Returns: TRUE, if the given handler is allo... | function field_has_translation_handler($entity_type, $handler = NULL) {
$entity_info = entity_get_info($entity_type);
if (isset($handler)) {
return !empty($entity_info['translation'][$handler]);
}
elseif (isset($entity_info['translation'])) {
foreach ($entity_info['translation'] as $handler_info) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ffb75b7429 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/request_uri/7.x | Implement `request_uri()` in PHP for Drupal 7. Required behavior: Returns the equivalent of Apache's $_SERVER['REQUEST_URI'] variable. | Because $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables.
File: includes/bootstrap.inc | function request_uri() {
if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
}
else {
if (isset($_SERVER['argv'])) {
$uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0];
}
elseif (isset($_SERVER['QUERY_STRING'])) {
$uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVE... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ffbc89c3d9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_preprocess_html/7.x | In Drupal 7, write the function `toolbar_preprocess_html(&$vars)` (file modules/toolbar/toolbar.module) so that it does the following: Implements hook_preprocess_html(). | Add some page classes, so global page theming can adjust to the toolbar.
File: modules/toolbar/toolbar.module | function toolbar_preprocess_html(&$vars) {
if (isset($vars['page']['page_top']['toolbar']) && user_access('access toolbar')) {
$vars['classes_array'][] = 'toolbar';
if (!_toolbar_is_collapsed()) {
$vars['classes_array'][] = 'toolbar-drawer';
}
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ffc0eb3759 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_user_delete/7.x | Implement `comment_user_delete($account)` in PHP for Drupal 7. Required behavior: Implements hook_user_delete(). | File: modules/comment/comment.module | function comment_user_delete($account) {
$cids = db_query('SELECT c.cid FROM {comment} c WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol();
comment_delete_multiple($cids);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ffc8f4e9d2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/statistics_block_info/7.x | I need the code for `statistics_block_info()` in Drupal 7 (modules/statistics/statistics.module). It must do this: Implements hook_block_info(). | File: modules/statistics/statistics.module | function statistics_block_info() {
$blocks = array();
if (variable_get('statistics_count_content_views', 0)) {
$blocks['popular']['info'] = t('Popular content');
// Too dynamic to cache.
$blocks['popular']['cache'] = DRUPAL_NO_CACHE;
}
return $blocks;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ffe08ce623 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_theme/7.x | I need the code for `update_theme()` in Drupal 7 (modules/update/update.module). It must do this: Implements hook_theme(). | File: modules/update/update.module | function update_theme() {
return array(
'update_manager_update_form' => array(
'render element' => 'form',
'file' => 'update.manager.inc',
),
'update_last_check' => array(
'variables' => array('last' => NULL),
),
'update_report' => array(
'variables' => array('data' => NULL... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ffe4a787c5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.admin.inc/function/_book_admin_table_tree/7.x | Implement `_book_admin_table_tree($tree, &$form)` in PHP for Drupal 7. Required behavior: Helps build the main table in the book administration page form. | Parameters:
- $tree: A subtree of the book menu hierarchy.
- $form: The form that is being modified, passed by reference.
Returns: The modified form array.
File: modules/book/book.admin.inc | function _book_admin_table_tree($tree, &$form) {
// The delta must be big enough to give each node a distinct value.
$count = count($tree);
$delta = ($count < 30) ? 15 : intval($count / 2) + 1;
foreach ($tree as $data) {
$form['book-admin-' . $data['link']['nid']] = array(
'#item' => $data['link'],
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ffeec1ee64 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_form_node_form_alter/7.x | In Drupal 7, write the function `forum_form_node_form_alter(&$form, &$form_state, $form_id)` (file modules/forum/forum.module) so that it does the following: Implements hook_form_BASE_FORM_ID_alter() for node_form(). | File: modules/forum/forum.module | function forum_form_node_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['taxonomy_forums'])) {
$langcode = $form['taxonomy_forums']['#language'];
// Make the vocabulary required for 'real' forum-nodes.
$form['taxonomy_forums'][$langcode]['#required'] = TRUE;
$form['taxonomy_forums'][$lan... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ffefb1d1bc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.pages.inc/function/book_remove_form/7.x | Implement `book_remove_form($form, &$form_state, $node)` in PHP for Drupal 7. Required behavior: Form constructor to confirm removal of a node from a book. | Parameters:
- $node: The node to delete.
File: modules/book/book.pages.inc | function book_remove_form($form, &$form_state, $node) {
$form['#node'] = $node;
$title = array('%title' => $node->title);
if ($node->book['has_children']) {
$description = t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hie... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fff2afc61c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_delete_multiple/7.x | I need the code for `user_delete_multiple(array $uids)` in Drupal 7 (modules/user/user.module). It must do this: Delete multiple user accounts. | Parameters:
- $uids: An array of user IDs.
File: modules/user/user.module | function user_delete_multiple(array $uids) {
if (!empty($uids)) {
$accounts = user_load_multiple($uids, array());
$transaction = db_transaction();
try {
foreach ($accounts as $uid => $account) {
module_invoke_all('user_delete', $account);
module_invoke_all('entity_delete', $account,... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-fff3b92d6f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_library/7.x | Implement `overlay_library()` in PHP for Drupal 7. Required behavior: Implements hook_library(). | File: modules/overlay/overlay.module | function overlay_library() {
$module_path = drupal_get_path('module', 'overlay');
// Overlay parent.
$libraries['parent'] = array(
'title' => 'Overlay: Parent',
'website' => 'http://drupal.org/documentation/modules/overlay',
'version' => '1.0',
'js' => array(
$module_path . '/overlay-parent... | [
"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.