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-77df0dc2a0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_bootstrap/7.x | Implement `drupal_bootstrap($phase = NULL, $new_phase = TRUE)` in PHP for Drupal 7. Required behavior: Ensures Drupal is bootstrapped to the specified phase. | In order to bootstrap Drupal from another PHP script, you can use this code:
Parameters:
- $phase (int): A constant telling which phase to bootstrap to. When you bootstrap to a particular phase, all earlier phases are run automatically. Possible values: - DRUPAL_BOOTSTRAP_CONFIGURATION: Initializes configuration. - DR... | function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
// Not drupal_static(), because does not depend on any run-time information.
static $phases = array(
DRUPAL_BOOTSTRAP_CONFIGURATION,
DRUPAL_BOOTSTRAP_PAGE_CACHE,
DRUPAL_BOOTSTRAP_DATABASE,
DRUPAL_BOOTSTRAP_VARIABLES,
DRUPAL_BOOTSTRAP_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-77e939b75b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.install/function/comment_update_7009/7.x | I need the code for `comment_update_7009()` in Drupal 7 (modules/comment/comment.install). It must do this: Change the last_comment_timestamp column description. | File: modules/comment/comment.install | function comment_update_7009() {
db_change_field('node_comment_statistics', 'last_comment_timestamp', 'last_comment_timestamp', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.changed.... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-78002ff848 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/update.php/function/update_extra_requirements/7.x | I need the code for `update_extra_requirements($requirements = NULL)` in Drupal 7 (update.php). It must do this: Returns and stores extra requirements that apply during the update process. | File: update.php | function update_extra_requirements($requirements = NULL) {
static $extra_requirements = array();
if (isset($requirements)) {
$extra_requirements += $requirements;
}
return $extra_requirements;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-780db17c64 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.api.php/function/hook_field_formatter_settings_summary/7.x | In Drupal 7, show an example implementation for `hook_field_formatter_settings_summary($field, $instance, $view_mode)` (modules/field_ui/field_ui.api.php): Return a short summary for the current formatter settings of an instance. | If an empty result is returned, the formatter is assumed to have no configurable settings, and no UI will be provided to display a settings form.
Parameters:
- $field: The field structure.
- $instance: The instance structure.
- $view_mode: The view mode for which a settings summary is requested.
Returns: A string con... | function hook_field_formatter_settings_summary($field, $instance, $view_mode) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$summary = '';
if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
$summary = t('Length: @chars chars', arra... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-78104d14e6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpc.inc/function/xmlrpc_message/7.x | In Drupal 7, write the function `xmlrpc_message($message)` (file includes/xmlrpc.inc) so that it does the following: Constructs an object representing an XML-RPC message. | Parameters:
- $message: A string containing an XML message.
Returns (object): An XML-RPC object containing the message.
File: includes/xmlrpc.inc | function xmlrpc_message($message) {
$xmlrpc_message = new stdClass();
// The stack used to keep track of the current array/struct
$xmlrpc_message->array_structs = array();
// The stack used to keep track of if things are structs or array
$xmlrpc_message->array_structs_types = array();
// A stack as well
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-781b2c8359 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpc.inc/function/xmlrpc_base64/7.x | Implement `xmlrpc_base64($data)` in PHP for Drupal 7. Required behavior: Returns an XML-RPC base 64 object. | Parameters:
- $data: Base 64 data to store in returned object.
Returns (object): An XML-RPC base 64 object.
File: includes/xmlrpc.inc | function xmlrpc_base64($data) {
$xmlrpc_base64 = new stdClass();
$xmlrpc_base64->is_base64 = TRUE;
$xmlrpc_base64->data = $data;
return $xmlrpc_base64;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-782251ebb8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.install/function/update_schema/7.x | I need the code for `update_schema()` in Drupal 7 (modules/update/update.install). It must do this: Implements hook_schema(). | File: modules/update/update.install | function update_schema() {
$schema['cache_update'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_update']['description'] = 'Cache table for the Update module to store information about available releases, fetched from central server.';
return $schema;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7842a20582 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_modules_uninstall_confirm_form/7.x | Implement `system_modules_uninstall_confirm_form($storage)` in PHP for Drupal 7. Required behavior: Confirm uninstall of selected modules. | Parameters:
- $storage: An associative array of modules selected to be uninstalled.
Returns: A form array representing modules to confirm.
File: modules/system/system.admin.inc | function system_modules_uninstall_confirm_form($storage) {
// Nothing to build.
if (empty($storage)) {
return;
}
// Construct the hidden form elements and list items.
foreach (array_filter($storage['uninstall']) as $module => $value) {
$info = drupal_parse_info_file(drupal_get_path('module', $module)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-78432d332a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.install/function/forum_enable/7.x | In Drupal 7, write the function `forum_enable()` (file modules/forum/forum.install) so that it does the following: Implements hook_enable(). | File: modules/forum/forum.install | function forum_enable() {
// If we enable forum at the same time as taxonomy we need to call
// field_associate_fields() as otherwise the field won't be enabled until
// hook modules_enabled is called which takes place after hook_enable events.
field_associate_fields('taxonomy');
// Create the forum vocabular... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-785161bdeb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.pages.inc/function/statistics_user_tracker/7.x | I need the code for `statistics_user_tracker()` in Drupal 7 (modules/statistics/statistics.pages.inc). It must do this: Page callback: Displays statistics for a user. | Returns (array): A render array containing user statistics. If information for the user was not found, this will deliver a page not found error via drupal_not_found().
File: modules/statistics/statistics.pages.inc | function statistics_user_tracker() {
if ($account = user_load(arg(1))) {
$header = array(
array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
array('data' => t('Page'), 'field' => 'path'),
array('data' => t('Operations')));
$query = db_select('accesslog', 'a', a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7857dc3b2f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_admin_config_page/7.x | In Drupal 7, write the function `system_admin_config_page()` (file modules/system/system.admin.inc) so that it does the following: Menu callback; Provide the administration overview page. | File: modules/system/system.admin.inc | function system_admin_config_page() {
// Check for status report errors.
if (system_status(TRUE) && user_access('administer site configuration')) {
drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array(... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-785a5f30bf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21content_types.inc/function/node_node_type_insert/7.x | I need the code for `node_node_type_insert($info)` in Drupal 7 (modules/node/content_types.inc). It must do this: Implements hook_node_type_insert(). | File: modules/node/content_types.inc | function node_node_type_insert($info) {
if (!empty($info->old_type) && $info->old_type != $info->type) {
$update_count = node_type_update_nodes($info->old_type, $info->type);
if ($update_count) {
drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7870157b4b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_field_settings_form/7.x | I need the code for `text_field_settings_form($field, $instance, $has_data)` in Drupal 7 (modules/field/modules/text/text.module). It must do this: Implements hook_field_settings_form(). | File: modules/field/modules/text/text.module | function text_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form = array();
if ($field['type'] == 'text') {
$form['max_length'] = array(
'#type' => 'textfield',
'#title' => t('Maximum length'),
'#default_value' => $settings['max_length'],
'#requ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-78709ead80 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_extra_fields_get_display/7.x | Implement `field_extra_fields_get_display($entity_type, $bundle, $view_mode)` in PHP for Drupal 7. Required behavior: Returns the display settings to use for pseudo-fields in a given view mode. | Parameters:
- $entity_type: The type of $entity; e.g., 'node' or 'user'.
- $bundle: The bundle name.
- $view_mode: The view mode.
Returns: The display settings to be used when viewing the bundle's pseudo-fields.
File: modules/field/field.module | function field_extra_fields_get_display($entity_type, $bundle, $view_mode) {
// Check whether the view mode uses custom display settings or the 'default'
// mode.
$view_mode_settings = field_view_mode_settings($entity_type, $bundle);
$actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings'])) ? ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-78835cdf73 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_permission/7.x | I need the code for `toolbar_permission()` in Drupal 7 (modules/toolbar/toolbar.module). It must do this: Implements hook_permission(). | File: modules/toolbar/toolbar.module | function toolbar_permission() {
return array(
'access toolbar' => array(
'title' => t('Use the administration toolbar'),
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-788f000e2d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.api.php/function/hook_taxonomy_term_update/7.x | Give me the example code for `hook_taxonomy_term_update($term)` in Drupal 7. Hook description: Act on taxonomy terms when updated. | Modules implementing this hook can act on the term object when updated.
Parameters:
- $term: A taxonomy term object.
File: modules/taxonomy/taxonomy.api.php | function hook_taxonomy_term_update($term) {
db_update('mytable')
->fields(array('foo' => $term->foo))
->condition('tid', $term->tid)
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-789e9dfdd2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.pages.inc/function/theme_filter_tips/7.x | Implement `theme_filter_tips($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a set of filter tips. | Parameters:
- $variables: An associative array containing: - tips: An array containing descriptions and a CSS ID in the form of 'module-name/filter-id' (only used when $long is TRUE) for each filter in one or more text formats. Example: @code array( 'Full HTML' => array( 0 => array( 'tip' => 'Web page addresses and e-m... | function theme_filter_tips($variables) {
$tips = $variables['tips'];
$long = $variables['long'];
$output = '';
$multiple = count($tips) > 1;
if ($multiple) {
$output = '<h2>' . t('Text Formats') . '</h2>';
}
if (count($tips)) {
if ($multiple) {
$output .= '<div class="compose-tips">';
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-78cf7fe83a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_requirements/7.x | Give me the example code for `hook_requirements($phase)` in Drupal 7. Hook description: Check installation requirements and do status reporting. | This hook has three closely related uses, determined by the $phase argument:
- Checking installation requirements ($phase == 'install').
- Checking update requirements ($phase == 'update').
- Status reporting ($phase == 'runtime').
Note that this hook, like all others dealing with installation and updates, must reside... | function hook_requirements($phase) {
$requirements = array();
// Ensure translations don't break during installation.
$t = get_t();
// Report Drupal version
if ($phase == 'runtime') {
$requirements['drupal'] = array(
'title' => $t('Drupal'),
'value' => VERSION,
'severity' => REQUIREMENT... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-78e732971b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.module/function/_simpletest_autoload_psr4_psr0/7.x | In Drupal 7, write the function `_simpletest_autoload_psr4_psr0($class)` (file modules/simpletest/simpletest.module) so that it does the following: Autoload callback to find PSR-4 and PSR-0 test classes. | Looks in the 'src/Tests' and in the 'lib/Drupal/mymodule/Tests' directory of modules for the class.
This will only work on classes where the namespace is of the pattern
"Drupal\$extension\Tests\.."
File: modules/simpletest/simpletest.module | function _simpletest_autoload_psr4_psr0($class) {
// Static cache for extension paths.
// This cache is lazily filled as soon as it is needed.
static $extensions;
// Check that the first namespace fragment is "Drupal\"
if (substr($class, 0, 7) === 'Drupal\\') {
// Find the position of the second namespa... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-78f8bb9d58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21image.inc/function/image_get_available_toolkits/7.x | In Drupal 7, write the function `image_get_available_toolkits()` (file includes/image.inc) so that it does the following: Gets a list of available toolkits. | Returns: An array with the toolkit names as keys and the descriptions as values.
File: includes/image.inc | function image_get_available_toolkits() {
// hook_image_toolkits returns an array of toolkit names.
$toolkits = module_invoke_all('image_toolkits');
$output = array();
foreach ($toolkits as $name => $info) {
// Only allow modules that aren't marked as unavailable.
if ($info['available']) {
$outpu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-78ff5cbbc2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_unmanaged_delete_recursive/7.x | In Drupal 7, write the function `file_unmanaged_delete_recursive($path)` (file includes/file.inc) so that it does the following: Deletes all files and directories in the specified filepath recursively. | If the specified path is a directory then the function will call itself recursively to process the contents. Once the contents have been removed the directory will also be removed.
If the specified path is a file then it will be passed to file_unmanaged_delete().
Note that this only deletes visible files with write p... | function file_unmanaged_delete_recursive($path) {
if (is_dir($path)) {
$dir = dir($path);
while (($entry = $dir->read()) !== FALSE) {
if ($entry == '.' || $entry == '..') {
continue;
}
$entry_path = $path . '/' . $entry;
file_unmanaged_delete_recursive($entry_path);
}
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-790b1e97b0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_pass_validate/7.x | I need the code for `user_pass_validate($form, &$form_state)` in Drupal 7 (modules/user/user.pages.inc). It must do this: Form validation handler for user_pass(). | File: modules/user/user.pages.inc | function user_pass_validate($form, &$form_state) {
if (isset($form_state['values']['name']) && !is_scalar($form_state['values']['name'])) {
form_set_error('name', t('An illegal value has been detected. Please contact the site administrator.'));
return;
}
$user_pass_reset_ip_window = variable_get('user_pas... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-790e849e6a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_link_maintain/7.x | I need the code for `menu_link_maintain($module, $op, $link_path, $link_title)` in Drupal 7 (includes/menu.inc). It must do this: Inserts, updates, or deletes an uncustomized menu link related to a module. | Parameters:
- $module: The name of the module.
- $op: Operation to perform: insert, update or delete.
- $link_path: The path this link points to.
- $link_title: Title of the link to insert or new title to update the link to. Unused for delete.
Returns: The insert op returns the mlid of the new item. Others op return N... | function menu_link_maintain($module, $op, $link_path, $link_title) {
switch ($op) {
case 'insert':
$menu_link = array(
'link_title' => $link_title,
'link_path' => $link_path,
'module' => $module,
);
return menu_link_save($menu_link);
break;
case 'update':
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-791380a544 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_profile_modules/7.x | In Drupal 7, write the function `install_profile_modules(&$install_state)` (file includes/install.core.inc) so that it does the following: Installs required modules via a batch process. | Parameters:
- $install_state: An array of information about the current installation state.
Returns: The batch definition.
File: includes/install.core.inc | function install_profile_modules(&$install_state) {
$modules = variable_get('install_profile_modules', array());
$files = system_rebuild_module_data();
variable_del('install_profile_modules');
// Always install required modules first. Respect the dependencies between
// the modules.
$required = array();
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7918022f4d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/theme_image_anchor/7.x | Implement `theme_image_anchor($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a 3x3 grid of checkboxes for image anchors. | Parameters:
- $variables: An associative array containing: - element: A render element containing radio buttons.
File: modules/image/image.admin.inc | function theme_image_anchor($variables) {
$element = $variables['element'];
$rows = array();
$row = array();
foreach (element_children($element) as $n => $key) {
$element[$key]['#attributes']['title'] = $element[$key]['#title'];
unset($element[$key]['#title']);
$row[] = drupal_render($element[$key]... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-79426aba01 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_init/7.x | I need the code for `system_init()` in Drupal 7 (modules/system/system.module). It must do this: Implements hook_init(). | File: modules/system/system.module | function system_init() {
$path = drupal_get_path('module', 'system');
// Add the CSS for this module. These aren't in system.info, because they
// need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
drupal_add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7962740b71 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/template_preprocess_username/7.x | I need the code for `template_preprocess_username(&$variables)` in Drupal 7 (includes/theme.inc). It must do this: Preprocesses variables for theme_username(). | Modules that make any changes to variables like 'name' or 'extra' must insure that the final string is safe to include directly in the output by using check_plain() or filter_xss().
File: includes/theme.inc | function template_preprocess_username(&$variables) {
$account = $variables['account'];
$variables['extra'] = '';
if (empty($account->uid)) {
$variables['uid'] = 0;
if (theme_get_setting('toggle_comment_user_verification')) {
$variables['extra'] = ' (' . t('not verified') . ')';
}
}
else {
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7985ed3b31 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_get_stream_wrappers/7.x | Implement `file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL)` in PHP for Drupal 7. Required behavior: Provides Drupal stream wrapper registry. | A stream wrapper is an abstraction of a file system that allows Drupal to use the same set of methods to access both local files and remote resources.
Provide a facility for managing and querying user-defined stream wrappers in PHP. PHP's internal stream_get_wrappers() doesn't return the class registered to handle a s... | function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
$wrappers_storage = &drupal_static(__FUNCTION__);
if (!isset($wrappers_storage)) {
$wrappers = module_invoke_all('stream_wrappers');
foreach ($wrappers as $scheme => $info) {
// Add defaults.
$wrappers[$scheme] += array('type' =... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-798b1ded06 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/theme_node_preview/7.x | Implement `theme_node_preview($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a node preview for display during node creation and editing. | Parameters:
- $variables: An associative array containing: - node: The node object which is being previewed.
File: modules/node/node.pages.inc | function theme_node_preview($variables) {
$node = $variables['node'];
$output = '<div class="preview">';
$preview_trimmed_version = FALSE;
$elements = node_view(clone $node, 'teaser');
$trimmed = drupal_render($elements);
$elements = node_view($node, 'full');
$full = drupal_render($elements);
// Do ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-798f791974 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.admin.inc/function/profile_admin_overview_submit/7.x | Implement `profile_admin_overview_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit handler to update changed profile field weights and categories. | File: modules/profile/profile.admin.inc | function profile_admin_overview_submit($form, &$form_state) {
foreach (element_children($form_state['values']) as $fid) {
if (is_numeric($fid)) {
$weight = $form_state['values'][$fid]['weight'];
$category = $form_state['values'][$fid]['category'];
if ($weight != $form[$fid]['weight']['#default_v... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-79933c95e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_predefined_form_submit/7.x | In Drupal 7, write the function `locale_languages_predefined_form_submit($form, &$form_state)` (file modules/locale/locale.admin.inc) so that it does the following: Process the language addition form submission. | File: modules/locale/locale.admin.inc | function locale_languages_predefined_form_submit($form, &$form_state) {
$langcode = $form_state['values']['langcode'];
if (isset($form_state['values']['name'])) {
// Custom language form.
locale_add_language($langcode, $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['di... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-79c88b49f8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_link_move_children/7.x | Implement `_menu_link_move_children($item, $existing_item)` in PHP for Drupal 7. Required behavior: Updates the children of a menu link that is being moved. | The menu name, parents (p1 - p6), and depth are updated for all children of the link, and the has_children status of the previous parent is updated.
File: includes/menu.inc | function _menu_link_move_children($item, $existing_item) {
$query = db_update('menu_links');
$query->fields(array('menu_name' => $item['menu_name']));
$p = 'p1';
$expressions = array();
for ($i = 1; $i <= $item['depth']; $p = 'p' . ++$i) {
$expressions[] = array($p, ":p_$i", array(":p_$i" => $item[$p]))... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-79ce5b7566 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_link_add_submit/7.x | I need the code for `shortcut_link_add_submit($form, &$form_state)` in Drupal 7 (modules/shortcut/shortcut.admin.inc). It must do this: Submit handler for shortcut_link_add(). | File: modules/shortcut/shortcut.admin.inc | function shortcut_link_add_submit($form, &$form_state) {
// Add the shortcut link to the set.
$shortcut_set = $form_state['values']['shortcut_set'];
$shortcut_link = $form_state['values']['shortcut_link'];
$shortcut_link['menu_name'] = $shortcut_set->set_name;
shortcut_admin_add_link($shortcut_link, $shortcut... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-79f965fc58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_move/7.x | In Drupal 7, write the function `file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME)` (file includes/file.inc) so that it does the following: Moves a file to a new location and update the file's database entry. | Moving a file is performed by copying the file to the new location and then
deleting the original.
- Checks if $source and $destination are valid and readable/writable.
- Performs a file move if $source is not equal to $destination.
- If file already exists in $destination either the call will error out,
replace the ... | function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
if (!file_valid_uri($destination)) {
if (($realpath = drupal_realpath($source->uri)) !== FALSE) {
watchdog('file', 'File %file (%realpath) could not be moved, because the destination %destination is invalid. This may ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7a0adc5057 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_merge/7.x | Implement `db_merge($table, array $options = array())` in PHP for Drupal 7. Required behavior: Returns a new MergeQuery object for the active database. | Parameters:
- $table: The table into which to merge.
- $options: An array of options to control how the query operates.
Returns: MergeQuery A new MergeQuery object for this connection.
File: includes/database/database.inc | function db_merge($table, array $options = array()) {
if (empty($options['target']) || $options['target'] == 'slave') {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->merge($table, $options);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7a23246d47 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.default.inc/function/field_default_insert/7.x | In Drupal 7, write the function `field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items)` (file modules/field/field.default.inc) so that it does the following: Default field 'insert' operation. | Insert default value if no $entity->$field_name entry was provided. This can happen with programmatic saves, or on form-based creation where the current user doesn't have 'edit' permission for the field.
File: modules/field/field.default.inc | function field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
// _field_invoke() populates $items with an empty array if the $entity has no
// entry for the field, so we check on the $entity itself.
// We also check that the current field translation is actually defined before
//... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7a4f38ad91 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_block_ip_action/7.x | I need the code for `system_block_ip_action()` in Drupal 7 (modules/system/system.module). It must do this: Blocks the current user's IP address. | File: modules/system/system.module | function system_block_ip_action() {
$ip = ip_address();
db_merge('blocked_ips')
->key(array('ip' => $ip))
->fields(array('ip' => $ip))
->execute();
watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7a661d3222 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_search_reset/7.x | I need the code for `node_search_reset()` in Drupal 7 (modules/node/node.module). It must do this: Implements hook_search_reset(). | File: modules/node/node.module | function node_search_reset() {
db_update('search_dataset')
->fields(array('reindex' => REQUEST_TIME))
->condition('type', 'node')
->execute();
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7a80ab6283 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_select_profile/7.x | Implement `install_select_profile(&$install_state)` in PHP for Drupal 7. Required behavior: Selects which profile to install. | Parameters:
- $install_state: An array of information about the current installation state. The chosen profile will be added here, if it was not already selected previously, as will a list of all available profiles.
Returns: For interactive installations, a form allowing the profile to be selected, if the user has a c... | function install_select_profile(&$install_state) {
$install_state['profiles'] += install_find_profiles();
if (empty($install_state['parameters']['profile'])) {
// Try to find a profile.
$profile = _install_select_profile($install_state['profiles']);
if (empty($profile)) {
// We still don't have a ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7a8775c188 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_access_acquire_grants/7.x | I need the code for `node_access_acquire_grants($node, $delete = TRUE)` in Drupal 7 (modules/node/node.module). It must do this: Gets the list of node access grants and writes them to the database. | This function is called when a node is saved, and can also be called by modules if something other than a node save causes node access permissions to change. It collects all node access grants for the node from hook_node_access_records() implementations, allows these grants to be altered via hook_node_access_records_al... | function node_access_acquire_grants($node, $delete = TRUE) {
$grants = module_invoke_all('node_access_records', $node);
// Let modules alter the grants.
drupal_alter('node_access_records', $grants, $node);
// If no grants are set and the node is published, then use the default grant.
if (empty($grants) && !em... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7aa5c7d178 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_get_recent/7.x | Implement `comment_get_recent($number = 10)` in PHP for Drupal 7. Required behavior: Find the most recent comments that are available to the current user. | Parameters:
- $number (integer): (optional) The maximum number of comments to find. Defaults to 10.
Returns: An array of comment objects or an empty array if there are no recent comments visible to the current user.
File: modules/comment/comment.module | function comment_get_recent($number = 10) {
$query = db_select('comment', 'c');
$query->innerJoin('node', 'n', 'n.nid = c.nid');
$query->addTag('node_access');
$comments = $query
->fields('c')
->condition('c.status', COMMENT_PUBLISHED)
->condition('n.status', NODE_PUBLISHED)
->orderBy('c.created... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7ab2c4fcbd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_category_load/7.x | In Drupal 7, write the function `user_category_load($uid, &$map, $index)` (file modules/user/user.module) so that it does the following: Return a user object after checking if any profile category in the path exists. | File: modules/user/user.module | function user_category_load($uid, &$map, $index) {
static $user_categories, $accounts;
// Cache $account - this load function will get called for each profile tab.
if (!isset($accounts[$uid])) {
$accounts[$uid] = user_load($uid);
}
$valid = TRUE;
if ($account = $accounts[$uid]) {
// Since the path ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7ab4e84eff | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_effect_apply/7.x | Implement `image_effect_apply($image, $effect)` in PHP for Drupal 7. Required behavior: Applies an image effect to the image object. | Parameters:
- $image: An image object returned by image_load().
- $effect: An image effect array.
Returns: TRUE on success. FALSE if unable to perform the image effect on the image.
File: modules/image/image.module | function image_effect_apply($image, $effect) {
module_load_include('inc', 'image', 'image.effects');
$function = $effect['effect callback'];
if (function_exists($function)) {
return $function($image, $effect['data']);
}
return FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7aca506e72 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_settings_form_validate/7.x | I need the code for `install_settings_form_validate($form, &$form_state)` in Drupal 7 (includes/install.core.inc). It must do this: Form validation handler for install_settings_form(). | File: includes/install.core.inc | function install_settings_form_validate($form, &$form_state) {
$driver = $form_state['values']['driver'];
$database = $form_state['values'][$driver];
$database['driver'] = $driver;
// TODO: remove when PIFR will be updated to use 'db_prefix' instead of
// 'prefix' in the database settings form.
$database['... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7aeca23c3b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_field_edit_instance_pre_render/7.x | Implement `field_ui_field_edit_instance_pre_render($element)` in PHP for Drupal 7. Required behavior: Pre-render function for field instance settings. | Combines the instance, widget, and other settings into a single fieldset so that elements within each group can be shown at different weights as if they all had the same parent.
File: modules/field_ui/field_ui.admin.inc | function field_ui_field_edit_instance_pre_render($element) {
// Merge the widget settings into the main form.
if (isset($element['widget']['settings'])) {
foreach (element_children($element['widget']['settings']) as $key) {
$element['widget_' . $key] = $element['widget']['settings'][$key];
}
unset... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7af6ef5a3d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_cookie_params/7.x | Implement `_drupal_cookie_params($options)` in PHP for Drupal 7. Required behavior: Process the params for cookies. This emulates support for the SameSite attribute in earlier versions of PHP, and allows the value of that attribute to be overridden. | Parameters:
- $options: An associative array which may have any of the keys expires, path, domain, secure, httponly, samesite.
Returns: An associative array which may have any of the keys expires, path, domain, secure, httponly, and samesite.
File: includes/bootstrap.inc | function _drupal_cookie_params($options) {
$options['samesite'] = _drupal_samesite_cookie($options);
if (\PHP_VERSION_ID < 70300) {
// Emulate SameSite support in older PHP versions.
if (!empty($options['samesite'])) {
// Ensure the SameSite attribute is only added once.
if (!preg_match('/SameSi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7af91b574b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/template_preprocess_book_export_html/7.x | In Drupal 7, write the function `template_preprocess_book_export_html(&$variables)` (file modules/book/book.module) so that it does the following: Processes variables for book-export-html.tpl.php. | Parameters:
- $variables: An associative array containing the following keys: - title - contents - depth
File: modules/book/book.module | function template_preprocess_book_export_html(&$variables) {
global $base_url, $language;
$variables['title'] = check_plain($variables['title']);
$variables['base_url'] = $base_url;
$variables['language'] = $language;
$variables['language_rtl'] = ($language->direction == LANGUAGE_RTL);
$variables['head'] =... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7afcda6cb9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.pages.inc/function/simpletest_test_form_submit/7.x | I need the code for `simpletest_test_form_submit($form, &$form_state)` in Drupal 7 (modules/simpletest/simpletest.pages.inc). It must do this: Run selected tests. | File: modules/simpletest/simpletest.pages.inc | function simpletest_test_form_submit($form, &$form_state) {
simpletest_classloader_register();
// Get list of tests.
$tests_list = array();
foreach ($form_state['values'] as $class_name => $value) {
// Since class_exists() will likely trigger an autoload lookup,
// we do the fast check first.
if ($v... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b020920f1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.pages.inc/function/contact_personal_form/7.x | In Drupal 7, write the function `contact_personal_form($form, &$form_state, $recipient)` (file modules/contact/contact.pages.inc) so that it does the following: Form constructor for the personal contact form. | Path: user/%user/contact
File: modules/contact/contact.pages.inc | function contact_personal_form($form, &$form_state, $recipient) {
global $user;
// Check if flood control has been activated for sending e-mails.
$limit = variable_get('contact_threshold_limit', 5);
$window = variable_get('contact_threshold_window', 3600);
if (!flood_is_allowed('contact', $limit, $window) &&... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b10fcabca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_token_info/7.x | Give me the example code for `hook_token_info()` in Drupal 7. Hook description: Provide information about available placeholder tokens and token types. | Tokens are placeholders that can be put into text by using the syntax [type:token], where type is the machine-readable name of a token type, and token is the machine-readable name of a token within this group. This hook provides a list of types and tokens to be displayed on text editing screens, so that people editing ... | function hook_token_info() {
$type = array(
'name' => t('Nodes'),
'description' => t('Tokens related to individual nodes.'),
'needs-data' => 'node',
);
// Core tokens for nodes.
$node['nid'] = array(
'name' => t("Node ID"),
'description' => t("The unique ID of the node."),
);
$node['tit... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7b1ebcd281 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_install_fix_file/7.x | In Drupal 7, write the function `drupal_install_fix_file($file, $mask, $message = TRUE)` (file includes/install.inc) so that it does the following: Attempts to fix file permissions. | The general approach here is that, because we do not know the security setup of the webserver, we apply our permission changes to all three digits of the file permission (i.e. user, group and all).
To ensure that the values behave as expected (and numbers don't carry from one digit to the next) we do the calculation o... | function drupal_install_fix_file($file, $mask, $message = TRUE) {
// If $file does not exist, fileperms() issues a PHP warning.
if (!file_exists($file)) {
return FALSE;
}
$mod = fileperms($file) & 0777;
$masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FI... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b24f9e020 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_field_attach_view_alter/7.x | In Drupal 7, write the function `rdf_field_attach_view_alter(&$output, $context)` (file modules/rdf/rdf.module) so that it does the following: Implements hook_field_attach_view_alter(). | File: modules/rdf/rdf.module | function rdf_field_attach_view_alter(&$output, $context) {
// Append term mappings on displayed taxonomy links.
foreach (element_children($output) as $field_name) {
$element = &$output[$field_name];
if ($element['#field_type'] == 'taxonomy_term_reference' && $element['#formatter'] == 'taxonomy_term_referenc... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7b2ecdd20a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21content_types.inc/function/node_type_form_submit/7.x | Implement `node_type_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for node_type_form(). | File: modules/node/content_types.inc | function node_type_form_submit($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
$type = node_type_set_defaults();
$type->type = $form_state['values']['type'];
$type->name = trim($form_state['values']['name']);
$type->orig_type = trim($form_state['values']['... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b3c3fad2c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.install/function/comment_update_dependencies/7.x | I need the code for `comment_update_dependencies()` in Drupal 7 (modules/comment/comment.install). It must do this: Implements hook_update_dependencies(). | File: modules/comment/comment.install | function comment_update_dependencies() {
// comment_update_7005() creates the comment body field and therefore must
// run after all Field modules have been enabled, which happens in
// system_update_7027().
$dependencies['comment'][7005] = array(
'system' => 7027,
);
// comment_update_7006() needs to ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7b45c6949f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_comment_update/7.x | In Drupal 7, write the function `search_comment_update($comment)` (file modules/search/search.module) so that it does the following: Implements hook_comment_update(). | File: modules/search/search.module | function search_comment_update($comment) {
// Reindex the node when comments are changed.
search_touch_node($comment->nid);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7b4cb9eccb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/module_invoke_all/7.x | I need the code for `module_invoke_all($hook)` in Drupal 7 (includes/module.inc). It must do this: Invokes a hook in all enabled modules that implement it. | All arguments are passed by value. Use drupal_alter() if you need to pass arguments by reference.
Parameters:
- $hook: The name of the hook to invoke.
Returns: An array of return values of the hook implementations. If modules return arrays from their implementations, those are merged into one array recursively. Note:... | function module_invoke_all($hook) {
$args = func_get_args();
// Remove $hook from the arguments.
unset($args[0]);
$return = array();
foreach (module_implements($hook) as $module) {
$function = $module . '_' . $hook;
if (function_exists($function)) {
$result = call_user_func_array($function, $arg... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b4f16a58d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_login_authenticate_validate/7.x | I need the code for `user_login_authenticate_validate($form, &$form_state)` in Drupal 7 (modules/user/user.module). It must do this: A validate handler on the login form. Check supplied username/password against local users table. If successful, $form_state['uid'] is set to the matching user ID. | File: modules/user/user.module | function user_login_authenticate_validate($form, &$form_state) {
$password = trim($form_state['values']['pass']);
if (!empty($form_state['values']['name']) && strlen(trim($password)) > 0) {
// Do not allow any login from the current user's IP if the limit has been
// reached. Default is 50 failed attempts a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b4f762f13 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_formatter_options/7.x | In Drupal 7, write the function `field_ui_formatter_options($field_type = NULL)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Returns an array of formatter options for a field type. | If no field type is provided, returns a nested array of all formatters, keyed by field type.
File: modules/field_ui/field_ui.admin.inc | function field_ui_formatter_options($field_type = NULL) {
$options = &drupal_static(__FUNCTION__);
if (!isset($options)) {
$field_types = field_info_field_types();
$options = array();
foreach (field_info_formatter_types() as $name => $formatter) {
foreach ($formatter['field types'] as $formatter_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b6a715eac | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7014/7.x | Implement `user_update_7014()` in PHP for Drupal 7. Required behavior: Rename the 'post comments without approval' permission. | In Drupal 7, this permission has been renamed to 'skip comment approval'.
File: modules/user/user.install | function user_update_7014() {
db_update('role_permission')
->fields(array('permission' => 'skip comment approval'))
->condition('permission', 'post comments without approval')
->execute();
return t("Renamed the 'post comments without approval' permission to 'skip comment approval'.");
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b6cd199f9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_restripe/7.x | Implement `ajax_command_restripe($selector)` in PHP for Drupal 7. Required behavior: Creates a Drupal Ajax 'restripe' command. | The 'restripe' command instructs the client to restripe a table. This is usually used after a table has been modified by a replace or append command.
This command is implemented by Drupal.ajax.prototype.commands.restripe() defined in misc/ajax.js.
Parameters:
- $selector: A jQuery selector string.
Returns: An array ... | function ajax_command_restripe($selector) {
return array(
'command' => 'restripe',
'selector' => $selector,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b6f27bbec | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/_field_filter_items/7.x | I need the code for `_field_filter_items($field, $items)` in Drupal 7 (modules/field/field.module). It must do this: Helper function to filter out empty field values. | Parameters:
- $field: The field definition.
- $items: The field values to filter.
Returns: The array of items without empty field values. The function also renumbers the array keys to ensure sequential deltas.
File: modules/field/field.module | function _field_filter_items($field, $items) {
$function = $field['module'] . '_field_is_empty';
foreach ((array) $items as $delta => $item) {
// Explicitly break if the function is undefined.
if ($function($item, $field)) {
unset($items[$delta]);
}
}
return array_values($items);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7b7085d003 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin_account/7.x | Implement `user_admin_account()` in PHP for Drupal 7. Required behavior: Form builder; User administration page. | File: modules/user/user.admin.inc | function user_admin_account() {
$header = array(
'username' => array('data' => t('Username'), 'field' => 'u.name'),
'status' => array('data' => t('Status'), 'field' => 'u.status'),
'roles' => array('data' => t('Roles')),
'member_for' => array('data' => t('Member for'), 'field' => 'u.created', 'sort' ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7bc8e34541 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_menu/7.x | Implement `locale_menu()` in PHP for Drupal 7. Required behavior: Implements hook_menu(). | File: modules/locale/locale.module | function locale_menu() {
// Manage languages
$items['admin/config/regional/language'] = array(
'title' => 'Languages',
'description' => 'Configure languages for content and the user interface.',
'page callback' => 'drupal_get_form',
'page arguments' => array('locale_languages_overview_form'),
'a... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7bd4835fd5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/debug/7.x | In Drupal 7, write the function `debug($data, $label = NULL, $print_r = FALSE)` (file includes/common.inc) so that it does the following: Outputs debug information. | The debug information is passed on to trigger_error() after being converted to a string using _drupal_debug_message().
Parameters:
- $data: Data to be output.
- $label: Label to prefix the data.
- $print_r: Flag to switch between print_r() and var_export() for data conversion to string. Set $print_r to TRUE when deali... | function debug($data, $label = NULL, $print_r = FALSE) {
// Print $data contents to string.
$string = check_plain($print_r ? print_r($data, TRUE) : var_export($data, TRUE));
// Display values with pre-formatting to increase readability.
$string = '<pre>' . $string . '</pre>';
trigger_error(trim($label ? "$l... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7c0797d442 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/theme_file_widget/7.x | Implement `theme_file_widget($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for an individual file upload widget. | Parameters:
- $variables: An associative array containing: - element: A render element representing the widget.
File: modules/file/file.field.inc | function theme_file_widget($variables) {
$element = $variables['element'];
$output = '';
// The "form-managed-file" class is required for proper Ajax functionality.
$output .= '<div class="file-widget form-managed-file clearfix">';
if ($element['fid']['#value'] != 0) {
// Add the file size after the file... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7c1ef0daa5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/image_field_widget_form/7.x | Implement `image_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)` in PHP for Drupal 7. Required behavior: Implements hook_field_widget_form(). | File: modules/image/image.field.inc | function image_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// Add display_field setting to field because file_field_widget_form() assumes it is set.
$field['settings']['display_field'] = 0;
$elements = file_field_widget_form($form, $form_state, $field, $inst... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7c31027d4b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_manager_cache_directory/7.x | In Drupal 7, write the function `_update_manager_cache_directory($create = TRUE)` (file modules/update/update.module) so that it does the following: Returns the directory where update archive files should be cached. | Parameters:
- $create: (optional) Whether to attempt to create the directory if it does not already exist. Defaults to TRUE.
Returns: The full path to the temporary directory where update file archives should be cached.
File: modules/update/update.module | function _update_manager_cache_directory($create = TRUE) {
$directory = &drupal_static(__FUNCTION__, '');
if (empty($directory)) {
$directory = 'temporary://update-cache-' . _update_manager_unique_identifier();
if ($create && !file_exists($directory)) {
mkdir($directory);
}
}
return $directory... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7c42fe32ad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_file_insert/7.x | In Drupal 7, show an example implementation for `hook_file_insert($file)` (modules/system/system.api.php): Respond to a file being added. | This hook is called after a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.
Parameters:
- $file: The file that has been added.
File: modules/system/system.api.php | function hook_file_insert($file) {
// Add a message to the log, if the file is a jpg
$validate = file_validate_extensions($file, 'jpg');
if (empty($validate)) {
watchdog('file', 'A jpg has been added.');
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7c5d2d5268 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/field_read_field/7.x | Implement `field_read_field($field_name, $include_additional = array())` in PHP for Drupal 7. Required behavior: Reads a single field record directly from the database. | Generally, you should use the field_info_field() instead.
This function will not return deleted fields. Use field_read_fields() instead for this purpose.
Parameters:
- $field_name: The field name to read.
- $include_additional (array): The default behavior of this function is to not return a field that is inactive. S... | function field_read_field($field_name, $include_additional = array()) {
$fields = field_read_fields(array('field_name' => $field_name), $include_additional);
return $fields ? current($fields) : FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7c64ea01fd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.admin.inc/function/comment_admin_overview/7.x | I need the code for `comment_admin_overview($form, &$form_state, $arg)` in Drupal 7 (modules/comment/comment.admin.inc). It must do this: Form builder for the comment overview administration form. | Parameters:
- $arg: Current path's fourth component: the type of overview form ('approval' or 'new').
File: modules/comment/comment.admin.inc | function comment_admin_overview($form, &$form_state, $arg) {
// Build an 'Update options' form.
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#attributes' => array('class' => array('container-inline')),
);
if ($arg == 'approval') {
$options['publish'] = t('P... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7c6a457b86 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/element_get_visible_children/7.x | In Drupal 7, write the function `element_get_visible_children(array $elements)` (file includes/common.inc) so that it does the following: Returns the visible children of an element. | Parameters:
- $elements: The parent element.
Returns: The array keys of the element's visible children.
File: includes/common.inc | function element_get_visible_children(array $elements) {
$visible_children = array();
foreach (element_children($elements) as $key) {
$child = $elements[$key];
// Skip un-accessible children.
if (isset($child['#access']) && !$child['#access']) {
continue;
}
// Skip value and hidden elem... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7ca015e13a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_object_prepare/7.x | Implement `node_object_prepare($node)` in PHP for Drupal 7. Required behavior: Prepares a node object for editing. | Fills in a few default values, and then invokes hook_prepare() on the node type module, and hook_node_prepare() on all modules.
Parameters:
- $node: A node object.
File: modules/node/node.module | function node_object_prepare($node) {
// Set up default values, if required.
$node_options = variable_get('node_options_' . $node->type, array('status', 'promote'));
// If this is a new node, fill in the default values.
if (!isset($node->nid) || isset($node->is_new)) {
foreach (array('status', 'promote', 's... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7cafccabda | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21theme.api.php/function/hook_themes_enabled/7.x | In Drupal 7, show an example implementation for `hook_themes_enabled($theme_list)` (modules/system/theme.api.php): Respond to themes being enabled. | Parameters:
- $theme_list (array): Array containing the names of the themes being enabled.
File: modules/system/theme.api.php | function hook_themes_enabled($theme_list) {
foreach ($theme_list as $theme) {
block_theme_initialize($theme);
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7cbe099b07 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_node_info/7.x | Implement `poll_node_info()` in PHP for Drupal 7. Required behavior: Implements hook_node_info(). | File: modules/poll/poll.module | function poll_node_info() {
return array(
'poll' => array(
'name' => t('Poll'),
'base' => 'poll',
'description' => t('A <em>poll</em> is a question with a set of possible responses. A <em>poll</em>, once created, automatically provides a simple running count of the number of votes received for e... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7cc7d489e2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_language_providers_url_form/7.x | In Drupal 7, write the function `locale_language_providers_url_form($form, &$form_state)` (file modules/locale/locale.admin.inc) so that it does the following: The URL language provider configuration form. | File: modules/locale/locale.admin.inc | function locale_language_providers_url_form($form, &$form_state) {
$form['locale_language_negotiation_url_part'] = array(
'#title' => t('Part of the URL that determines language'),
'#type' => 'radios',
'#options' => array(
LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX => t('Path prefix'),
LOCALE_LANG... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7ccd72ef4a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21syslog%21syslog.module/function/syslog_form_system_logging_settings_alter/7.x | In Drupal 7, write the function `syslog_form_system_logging_settings_alter(&$form, &$form_state)` (file modules/syslog/syslog.module) so that it does the following: Implements hook_form_FORM_ID_alter(). | File: modules/syslog/syslog.module | function syslog_form_system_logging_settings_alter(&$form, &$form_state) {
$help = module_exists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL;
$form['syslog_identity'] = array(
'#type' => 'textfield',
'#title' => t('Syslog identity'),
'#default_value' => va... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7ccf0071d4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_anonymous_user/7.x | In Drupal 7, write the function `drupal_anonymous_user()` (file includes/bootstrap.inc) so that it does the following: Generates a default anonymous $user object. | Returns (Object): - the user object.
File: includes/bootstrap.inc | function drupal_anonymous_user() {
$user = variable_get('drupal_anonymous_user_object', new stdClass);
$user->uid = 0;
$user->hostname = ip_address();
$user->roles = array();
$user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
$user->cache = 0;
return $user;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7cdda53ef7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_message_action/7.x | Implement `system_message_action(&$entity, $context = array())` in PHP for Drupal 7. Required behavior: Sends a message to the current user's screen. | Parameters:
- $entity (object): An optional node object, which will be added as $context['node'] if provided.
- $context (array): Array with the following elements: - 'message': The message to send. This will be passed through token_replace(). - Other elements will be used as the data for token replacement in the messa... | function system_message_action(&$entity, $context = array()) {
if (empty($context['node'])) {
$context['node'] = $entity;
}
$context['message'] = token_replace(filter_xss_admin($context['message']), $context);
drupal_set_message($context['message']);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7cf3828e21 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_login_validate/7.x | In Drupal 7, write the function `openid_login_validate($form, &$form_state)` (file modules/openid/openid.module) so that it does the following: Login form _validate hook | File: modules/openid/openid.module | function openid_login_validate($form, &$form_state) {
$return_to = $form_state['values']['openid.return_to'];
if (empty($return_to)) {
$return_to = url('', array('absolute' => TRUE));
}
openid_begin($form_state['values']['openid_identifier'], $return_to, $form_state['values']);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d0030023c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_batch_alter/7.x | In Drupal 7, show an example implementation for `hook_batch_alter(&$batch)` (modules/system/system.api.php): Alter batch information before a batch is processed. | Called by batch_process() to allow modules to alter a batch before it is processed.
Parameters:
- $batch: The associative array of batch information. See batch_set() for details on what this could contain.
File: modules/system/system.api.php | function hook_batch_alter(&$batch) {
// If the current page request is inside the overlay, add ?render=overlay to
// the success callback URL, so that it appears correctly within the overlay.
if (overlay_get_mode() == 'child') {
if (isset($batch['url_options']['query'])) {
$batch['url_options']['query']... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7d32f687ae | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/theme_node_recent_block/7.x | In Drupal 7, write the function `theme_node_recent_block($variables)` (file modules/node/node.module) so that it does the following: Returns HTML for a list of recent content. | Parameters:
- $variables: An associative array containing: - nodes: An array of recent node objects.
File: modules/node/node.module | function theme_node_recent_block($variables) {
$rows = array();
$output = '';
$l_options = array('query' => drupal_get_destination());
foreach ($variables['nodes'] as $node) {
$row = array();
$row[] = array(
'data' => theme('node_recent_content', array('node' => $node)),
'class' => 'title-a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d3faee489 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_translate_seek/7.x | In Drupal 7, write the function `_locale_translate_seek()` (file includes/locale.inc) so that it does the following: Perform a string search and display results in a table | File: includes/locale.inc | function _locale_translate_seek() {
$output = '';
// We have at least one criterion to match
if (!($query = _locale_translate_seek_query())) {
$query = array(
'translation' => 'all',
'group' => 'all',
'language' => 'all',
'string' => '',
);
}
$sql_query = db_select('locales_s... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d4a48f8e7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_invalid_openid_transition/7.x | Implement `_openid_invalid_openid_transition($identity, $response)` in PHP for Drupal 7. Required behavior: Provides transition for accounts with possibly invalid OpenID identifiers in authmap. | This function provides a less safe but more unobtrusive procedure for users who cannot login with their OpenID identifiers. OpenID identifiers in the authmap could be incomplete due to invalid OpenID implementation in previous versions of Drupal (e.g. fragment part of the identifier could be missing). For more informat... | function _openid_invalid_openid_transition($identity, $response) {
$account = FALSE;
$fallback_account = NULL;
$fallback_identity = $identity;
// Try to strip the fragment if it is present.
if (strpos($fallback_identity, '#') !== FALSE) {
$fallback_identity = preg_replace('/#.*/', '', $fallback_identity)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d504edffa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/get_t/7.x | I need the code for `get_t()` in Drupal 7 (includes/bootstrap.inc). It must do this: Returns the name of the proper localization function. | get_t() exists to support localization for code that might run during the installation phase, when some elements of the system might not have loaded.
This would include implementations of hook_install(), which could run during the Drupal installation phase, and might also be run during non-installation time, such as w... | function get_t() {
static $t;
// This is not converted to drupal_static because there is no point in
// resetting this as it can not change in the course of a request.
if (!isset($t)) {
$t = drupal_installation_attempted() ? 'st' : 't';
}
return $t;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d64158916 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/theme_dashboard/7.x | I need the code for `theme_dashboard($variables)` in Drupal 7 (modules/dashboard/dashboard.module). It must do this: Returns HTML for the entire dashboard. | 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($variables) {
extract($variables);
drupal_add_css(drupal_get_path('module', 'dashboard') . '/dashboard.css');
return '<div id="dashboard" class="clearfix">' . $element['#children'] . '</div>';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d6a4d020b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.admin.inc/function/search_reindex_confirm_submit/7.x | In Drupal 7, write the function `search_reindex_confirm_submit(&$form, &$form_state)` (file modules/search/search.admin.inc) so that it does the following: Handler for wipe confirmation | File: modules/search/search.admin.inc | function search_reindex_confirm_submit(&$form, &$form_state) {
if ($form['confirm']) {
search_reindex();
drupal_set_message(t('The index will be rebuilt.'));
$form_state['redirect'] = 'admin/config/search/settings';
return;
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d76aca544 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7007/7.x | Implement `system_update_7007()` in PHP for Drupal 7. Required behavior: Convert to new method of storing permissions. | File: modules/system/system.install | function system_update_7007() {
// Copy the permissions from the old {permission} table to the new {role_permission} table.
$messages = array();
$result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid ASC");
$query = db_insert('role_permission')->fields(array('rid', 'permission'));
foreach ($resul... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d76f5e18c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.effects.inc/function/image_scale_and_crop_effect/7.x | I need the code for `image_scale_and_crop_effect(&$image, $data)` in Drupal 7 (modules/image/image.effects.inc). It must do this: Image effect callback; Scale and crop an image resource. | Parameters:
- $image: An image object returned by image_load().
- $data: An array of attributes to use when performing the scale and crop effect with the following items: - "width": An integer representing the desired width in pixels. - "height": An integer representing the desired height in pixels.
Returns: TRUE on s... | function image_scale_and_crop_effect(&$image, $data) {
if (!image_scale_and_crop($image, $data['width'], $data['height'])) {
watchdog('image', 'Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d7b3c4b48 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/_node_access_rebuild_batch_operation/7.x | In Drupal 7, write the function `_node_access_rebuild_batch_operation(&$context)` (file modules/node/node.module) so that it does the following: Implements callback_batch_operation(). | Performs batch operation for node_access_rebuild().
This is a multistep operation: we go through all nodes by packs of 20. The batch processing engine interrupts processing and sends progress feedback after 1 second execution time.
Parameters:
- $context (array): An array of contextual key/value information for rebui... | function _node_access_rebuild_batch_operation(&$context) {
if (empty($context['sandbox'])) {
// Initiate multistep processing.
$context['sandbox']['progress'] = 0;
$context['sandbox']['current_node'] = 0;
$context['sandbox']['max'] = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
}
// P... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7d9beb9e98 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_revision_revert_confirm_submit/7.x | Implement `node_revision_revert_confirm_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for node_revision_revert_confirm(). | File: modules/node/node.pages.inc | function node_revision_revert_confirm_submit($form, &$form_state) {
$node_revision = $form['#node_revision'];
$node_revision->revision = 1;
$node_revision->log = t('Copy of the revision from %date.', array('%date' => format_date($node_revision->revision_timestamp)));
node_save($node_revision);
watchdog('con... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7da6194417 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_role_presave/7.x | Give me the example code for `hook_user_role_presave($role)` in Drupal 7. Hook description: Act on a user role being inserted or updated. | Modules implementing this hook can act on the user role object before it has been saved to the database.
Parameters:
- $role: A user role object.
File: modules/user/user.api.php | function hook_user_role_presave($role) {
// Set a UUID for the user role if it doesn't already exist
if (empty($role->uuid)) {
$role->uuid = uuid_uuid();
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7da7004ce0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.admin.inc/function/path_admin_delete_confirm_submit/7.x | In Drupal 7, write the function `path_admin_delete_confirm_submit($form, &$form_state)` (file modules/path/path.admin.inc) so that it does the following: Form submission handler for path_admin_delete_confirm(). | File: modules/path/path.admin.inc | function path_admin_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
path_delete($form_state['path']['pid']);
$form_state['redirect'] = 'admin/config/search/path';
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7dbd617994 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/image_field_formatter_settings_form/7.x | I need the code for `image_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)` in Drupal 7 (modules/image/image.field.inc). It must do this: Implements hook_field_formatter_settings_form(). | File: modules/image/image.field.inc | function image_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$image_styles = image_style_options(FALSE, PASS_THROUGH);
$element['image_style'] = array(
'#title' => t('Image style'),
'#ty... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7dd0edb4a8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_contextual_links_alter/7.x | In Drupal 7, show an example implementation for `hook_menu_contextual_links_alter(&$links, $router_item, $root_path)` (modules/system/system.api.php): Alter contextual links before they are rendered. | This hook is invoked by menu_contextual_links(). The system-determined contextual links are passed in by reference. Additional links may be added or existing links can be altered.
Each contextual link must at least contain:
- title: The localized title of the link.
- href: The system path to link to.
- localized_optio... | function hook_menu_contextual_links_alter(&$links, $router_item, $root_path) {
// Add a link to all contextual links for nodes.
if ($root_path == 'node/%') {
$links['foo'] = array(
'title' => t('Do fu'),
'href' => 'foo/do',
'localized_options' => array(
'query' => array(
'foo... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7de23d17e3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21path.inc/function/drupal_clear_path_cache/7.x | Implement `drupal_clear_path_cache($source = NULL)` in PHP for Drupal 7. Required behavior: Clear the path cache. | Parameters:
- $source: An optional system path for which an alias is being changed.
File: includes/path.inc | function drupal_clear_path_cache($source = NULL) {
// Clear the drupal_lookup_path() static cache.
drupal_static_reset('drupal_lookup_path');
drupal_path_alias_whitelist_rebuild($source);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7df3ab0134 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.api.php/function/hook_openid_normalization_method_info_alter/7.x | In Drupal 7, show an example implementation for `hook_openid_normalization_method_info_alter(&$methods)` (modules/openid/openid.api.php): Allow modules to alter normalization methods. | File: modules/openid/openid.api.php | function hook_openid_normalization_method_info_alter(&$methods) {
// Remove Google IDP normalization.
unset($methods['google_idp']);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7df9ce5d8a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/theme_menu_overview_form/7.x | In Drupal 7, write the function `theme_menu_overview_form($variables)` (file modules/menu/menu.admin.inc) so that it does the following: Returns HTML for the menu overview form into a table. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/menu/menu.admin.inc | function theme_menu_overview_form($variables) {
$form = $variables['form'];
drupal_add_tabledrag('menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, MENU_MAX_DEPTH - 1);
drupal_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');
$header = array(
t('Menu link'),
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e0ac40e1c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_excerpt/7.x | I need the code for `search_excerpt($keys, $text)` in Drupal 7 (modules/search/search.module). It must do this: Returns snippets from a piece of text, with certain keywords highlighted. Used for formatting search results. | Parameters:
- $keys: A string containing a search query.
- $text: The text to extract fragments from.
Returns: A string containing HTML for the excerpt.
File: modules/search/search.module | function search_excerpt($keys, $text) {
// We highlight around non-indexable or CJK characters.
$boundary = '(?:(?<=[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . PREG_CLASS_CJK . '])|(?=[' . PREG_CLASS_UNICODE_WORD_BOUNDARY . PREG_CLASS_CJK . ']))';
// Extract positive keywords and phrases
preg_match_all('/ ("([^"]+... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e0e439fb4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21batch.inc/function/_batch_current_set/7.x | In Drupal 7, write the function `&_batch_current_set()` (file includes/batch.inc) so that it does the following: Returns the batch set being currently processed. | File: includes/batch.inc | function &_batch_current_set() {
$batch = &batch_get();
return $batch['sets'][$batch['current_set']];
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e1a843445 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.install/function/taxonomy_update_7004/7.x | In Drupal 7, write the function `taxonomy_update_7004()` (file modules/taxonomy/taxonomy.install) so that it does the following: Move taxonomy vocabulary associations for nodes to fields and field instances. | File: modules/taxonomy/taxonomy.install | function taxonomy_update_7004() {
$taxonomy_index = array(
'description' => 'Maintains denormalized information about node/term relationships.',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
... | [
"code-task",
"function"
] | 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.