I can get the form to display in my sidebar but it doesn't send an email. It also doesn't show a confirmation that an email was sent. It just redirects to Home page after "send." I tried both methods above. Three things i have a question about. In both methods it seems that you are saying to add field "(author) User: E-mail", but then what is the purpose of the custom email field? This could be where I'm messing up. I create the email field in my user profile and populate it but it doesn't seem that its never called on. Second, when creating the block what do i select to "show"? I'm assuming i select the content that i want the block to be present. in my case its classified ads which are nodes. Third, contextual filter. Properties of Content: NID...do i just use what is default?

Backgroud of what I'm trying to do. I have a view that displays a list of ads. Users click on an ad which takes them to the main full ad/node. From here i want users to be able to contact the seller referencing the ad they are viewing. IOW I would like the seller/author to receive an email that has the comment/question plus the ad/node title included. I like your module because it appears that if i can get it to work none of the users will have to leave the page/ad/node to send the seller a message. I also would like no redirect. The visitor will stay on the ad/node.

I've tried all the "contact" modules I could find and they all come up short on what i need. Your module is the closest to what I want.

Thank you so much for any assistance. This is the final leg of my project and it's your module that i need. I'm willing to pay for any extensive customization.

Mark

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

System Lord’s picture

Assigned: System Lord » Unassigned
Issue summary: View changes
System Lord’s picture

Issue summary: View changes
matthieu_collet’s picture

hello Mark

I have exactly the same problems. did you find an issue ?

thanks

System Lord’s picture

I'm using /project/privatemsg. I like it b/c it takes email completely out of the equation. The "Send author a message" takes the user away from the page/ad, but once submitted it returns. It also prepopulates the "Subject" field, which is ideal.

matthieu_collet’s picture

good idea. in my case I use "contact form on node", wich also prepopulates the subject field

contact_form_on_node

System Lord’s picture

Yes, i reviewed that module and like it. It will be my fall-back if privatemsg fails testing phase.

Pol’s picture

Hi there,

Did you succeeded to understand how the module works ?

matthieu_collet’s picture

no, the other was simpler, sorry

Pol’s picture

Status: Active » Fixed
Issue tags: -Functionality

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sgabe’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Component: Miscellaneous » Code
Assigned: Unassigned » sgabe
Category: Support request » Bug report
Status: Closed (fixed) » Needs review
FileSize
1.75 KB

I recently ran into the same issue:

  • The module does nothing just redirects to the front page... (action is /)
  • There is an odd Save button at the bottom of the form... (whole thing is wrapped in another form tag)

#2146119: 'Save' button appears on contact form seems to be a duplicate of this.

I did some investigation and found that the culprit is the view_form() function which should not be overridden (at least I did not see this anywhere in the docs), instead the module should override the render() function.

The attached patch removes the view_form() function and implements render() instead.


class views_contact_form_handler extends views_handler_field_user_mail {

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['link_to_user']['#options']['views_contact_form'] = t('Contact form');
  }

  function render($values) {
    if ($this->options['link_to_user'] == 'views_contact_form') {
      // The view is empty, abort.
      if (empty($this->view->result)) {
        return;
      }

      $emails = array();
      foreach ($this->view->result as $row_index => $row) {
        $emails[] = $this->get_value($row);
      }

      if (empty($emails)) {
        return;
      }

      $data['emails'] = $emails;
      $form = drupal_get_form('views_contact_form_contact_form', $data);

      return drupal_render($form);
    }

    // Fallback to the default behavior.
    $value = $this->get_value($values);
    return $this->render_link($this->sanitize_value($value), $values);
  }

}

Pol’s picture

Amazing ! Nice find, I wasn't able to isolate the problem.

I will try the patch tonight and if everything goes well, commit it and release a new version too.

For the record, I used views_form() because someone on IRC (dawehner or berdir, I don't remember) told me to use it.

Anyway, thanks a lot !

balajidharma’s picture

Status: Needs review » Needs work

#2144153-11: Not functioning patch not working, display empty views

balajidharma’s picture

Status: Needs work » Needs review
FileSize
1.68 KB

I changed render function of @sgabe patch

views_contact_form_handler.inc

<?php

class views_contact_form_handler extends views_handler_field_user_mail {

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['link_to_user']['#options']['views_contact_form'] = t('Contact form');
  }

  function render($values) {
    if ($this->options['link_to_user'] == 'views_contact_form') {
      // The view is empty, abort.
      if (empty($this->view->result)) {
        return;
      }
      $emails = array();
      foreach ($this->view->result as $row_index => $row) {
        $emails[] = $this->get_value($row);
      }
      if (empty($emails)) {
        return;
      }
	  $value = $this->get_value($values);
      return $this->sanitize_value($value);
    }
    // Fallback to the default behavior.
    $value = $this->get_value($values);
    return $this->render_link($this->sanitize_value($value), $values);
  }
 
}

?>
sgabe’s picture

And how are you displaying the contact form without these lines?

  $form = drupal_get_form('views_contact_form_contact_form', $data);
  return drupal_render($form);
balajidharma’s picture

@sgabe your patch is working fine. I selected both the options in views (Format views contact form and Link this field as contact form in field configuration). Sorry for this mistake.

balajidharma’s picture

Pol’s picture

Could you please upgrade to dev version, I just committed a fix for this and a bunch of other things.

Commit: http://cgit.drupalcode.org/views_contact_form/commit/?id=62d37ae

Pol’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.