This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Field for phone number on contact form

I wanted a field on my site-wide contact form for the user's phone number. Here's the code I added to my module in hook_form_alter() to add it:

// Add phone number to contact mail page
  if ($form_id == 'contact_mail_page') {
    $form['phone'] = array(
      '#type' => 'textfield',
      '#title' => t('Your phone number'),
      '#maxlength' => 255,
      '#default_value' => $edit['phone'],
      '#required' => false,
    );
    $form['name']['#weight'] = 0;
    $form['mail']['#weight'] = 2;
    $form['phone']['#weight'] = 4;
    $form['subject']['#weight'] = 6;
    $form['message']['#weight'] = 8;
    $form['copy']['#weight'] = 9;
    $form['submit']['#weight'] = 10;

    // Add the phone number to the email
    if ($_POST['edit']['phone']) {
      $_POST['edit']['message'] = t('Phone number: ') . $_POST['edit']['phone'] . "\n\n" . $_POST['edit']['message'];
    };
  }

You can see my implementation on my yearbook website.

What this does is adds a field for phone number and on submission of the form, it puts the phone number into the top of the body field.

The only problem is that if the user's form doesn't validate (e.g. they leave out the subject field) then when the form comes back to them to complete the phone number will already have been added to the subject field, as well as being in the phone field. Hence when they submit again, you will have the phone number twice.

static pages for authenticated users only

I'm in the process of converting a site to Drupal that has a large number of (mostly html) pages that are restricted to members. I'd like to have it so any link to one of these pages forces a check that the person is logged in on drupal and then serves the page as normal (and all of the subsequent graphics etc.)

I've put this restricted tree into the drupal directory and have been fiddling with .htaccess permissions, but is there any way short of registering every individual page as drupal files in the database?

Thanks for any pointers.

How to create a topic????

Hi,
I was trying to create a module, but failed. I had asked for a tutorial before. Some helped me with the handbook and the IBM tutorial. But that didn suit my needs.

The handbook has provided an example, but that doesnot explain why each part of a code is meant for.

Password Protect Nodes

I created a module that allows users to set passwords for the node. If the password exists, the node is not loaded unless the password is correct.

The password check is done in the hook_load() function of my node. It checks the $_SESSION variable for the password. If the password is incorrect or empty, it redirects(drupal_goto()) the user to the form that allows the user to insert the password.

New Content type: fields outout as table w/ column/row

I'm new to Drupal. I've got the CCK installed and am playing with creating content-types and adding fields.

I want the viewers to see all the content entries as a table with the fields as columns and entries as rows (i.e. pretty much looking like a database table). How do I modify the view to display as a table?

Change behavior on book module

I just want to to change the way the children are displayed inside a book. Regularly, when a book has children, these are displayed as links, so, I don´t wanna links but the content so the users will be able to check the entire book in the same page.

The book module has this structure...

Mesoamerica
A little introduction to the book.

----------------------------
* Primera Parte (as a link)
* Segunda Parte (as a link)
_________________________
Primera Parte >(as a link)

I want to this other way.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions