Pass parameter to drupal_get_form

<?php /** * Implements hook_menu(). */ $msx = ‘DDDDD’; function f2_menu() { $items = array(); $items[‘f2/form’] = array( ‘title’ => t(‘My form’), ‘page callback’ => ‘drupal_get_form’, ‘page arguments’ => array(‘f2_my_form’), ‘access arguments’ => array(‘access content’), ‘description’ => t(‘My form’), ‘type’ => MENU_CALLBACK, ); return $items;[…]

.htaccess warning message

I receive this warning after changing .htaccess files to re-direct from the site root to the Drupal root located in a sub-folder. Warning: file_put_contents(private:///.htaccess): failed to open stream: “DrupalPrivateStreamWrapper::stream_open” call failed in file_create_htaccess() (line 496 of /home/sites/dartmoorchurches.org/public_html/live/includes/file.inc). So far everything seems to work ok but[…]

Connect to Drupal database from outside Drupal

I have found several examples that suggest the code below should display the results of a database query. chdir(‘/home/sites/zzzzzz.org/public_html/mmclone1’) include_once(‘./includes/bootstrap.inc’); drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); $result = db_query(‘SELECT title FROM {node}’); print_r ($result); Drupal is installed in a sub-folder off public_html, mmclone1. I have checked the path with getcwd().[…]

What is $attributes?

I cannot find any documentation with explains the $attributes variable which appears in a line in node.tpl.php. <div id=”node-<?php print $node->nid; ?>” class=”<?php print $classes; ?> clearfix”<?php print $attributes; ?> I have found the function in template.php which creates $classes but nothing for $attributes.  I’d[…]

Set a form field as read only

I am using this code to set the field field_locked as read-only on the content type with machine name prices <?php /** * Implements hook_form_alter(). */ function example_form2_alter(&$form, &$form_state, $form_id) { if ($form_id == $form[‘#node’]->type .’prices’) { $form[‘#after_build’][] = ‘example_after_build’; } } function example_after_build($form, &$form_state)[…]

Ajax Custom Form – Remove previous value when re-displayed

This code function demo_demo_form($form, &$form_state) { return array( ’email’ => array( ‘#type’ => ‘textfield’, ‘#title’ => t(‘Please supply email address’), ‘#required’ => TRUE, ‘#attributes’ => array( ‘placeholder’ => t(‘[email protected]’), ), ), ‘submit’ => array( ‘#type’ => ‘submit’, ‘#value’ => t(‘Subscribe’), ‘#ajax’ => array( ‘callback’ =>[…]

Error messages that cause no problems but…

These error messages appear on every Drupal site that I run on a hosted server: Notice: Undefined offset: 1 in drupal_http_request() (line 994 of /home/sites/zzzzzz.com/public_html/drmp2/includes/common.inc). Notice: Undefined offset: 1 in _drupal_parse_response_status() (line 1128 of /home/sites/zzzzzz.com/public_html/drmp2/includes/common.inc). I have looked up the code lines mentioned and these are shown below. The errors seem to have no effect[…]