Ajax Autocomplete Textfield drupal

function module_name_form() { $form = array(); $form[‘city’] = array( ‘#title’ => t(‘City’), ‘#type’ => ‘textfield’, ‘#autocomplete_path’ => ‘example/autocomplete’, ); $form[‘submit’] = array( ‘#type’ => ‘submit’, ‘#value’ => ‘Save’, ); return $form; } function module_name_menu() { $items[‘example/autocomplete’] = array( ‘page callback’ => ‘_module_name_autocomplete’, ‘access arguments’ => array(‘access example autocomplete’), ‘type’ => MENU_CALLBACK ); return $items; }… Continue reading Ajax Autocomplete Textfield drupal

Displaying a different theme for each day of the week drupal

<?php /** * Implements hook_custom_theme(). */ function mymodule_custom_theme() { // An array of themes for each day of the week. // These themes have to be installed and enabled. $themes = array(); $themes[0] = ‘monday_theme’; $themes[1] = ‘tuesday_theme’; .. // Get the current day of the week in numerical form. $day = date(“w”); // Override… Continue reading Displaying a different theme for each day of the week drupal

Export CSV file Drupal

// send response headers to the browser drupal_add_http_header(‘Content-Type’, ‘text/csv’); drupal_add_http_header(‘Content-Disposition’, ‘attachment;filename=csvfile.csv’); $csv_array = array( array(‘one’, ‘two’, ‘three’), array(‘1’, ‘2’, ‘3’), ); $fp = fopen(‘php://output’, ‘w’); foreach($csv_array as $line){ fputcsv($fp, $line); } fclose($fp); drupal_exit();