Hi, I love the idea of this module, but I'm wondering if it will suit my needs. Basically I just need a button for a mobile site that would add a share link that would then open up their mobile mail program to send a pre-populated message based on the current node id. I understand that right now this just works with Rules, and maybe I should post there, but thought I'd ask here first. Thanks!

Comments

BassistJimmyJam’s picture

You may be able to use a page redirect rule with a URL of mailto:email@example.com?subject=foo&body=bar. I'm not sure how well this works on mobile platforms but it does work with a standard browser.

CinemaSaville’s picture

The only issue I have is how exactly does this work. Also what if I want the recipient field to be filled in by the user? And how would I implement the node id in that statement? Thanks for your help.

CinemaSaville’s picture

Hi JimmyJam,

I tried redirecting in rules, and nothing happens. I also tried printing a system message, and nothing happened until I refreshed the page.

BassistJimmyJam’s picture

When you send a system message you have to refresh the page in order to see it (see #663732: How can I make Rules show a message on the current page without a refresh?). Depending on the mobile device and browser, you may not be able to launch a mailto link using JavaScript's location.href, which is what this module uses for page redirection. I would start with a simple button with a Page redirect Rule with a URL of mailto:yourmail@foo.com. If this does not work, it may be a mobile device issue.

BassistJimmyJam’s picture

If there are no Rules to accomplish what you are looking for, you may have to write your own. You can find the Rules documentation at http://drupal.org/node/298476. If you want your Rule to have a more dynamic URL you can write a Rule that accepts tokens, or write a Rule that just reads the values straight from the database if you don't plan on re-using it.

If you want the user to enter the recipients email address on the form that the button appears on, you will need to have them save the node before clicking on the send button. This certainly isn't desired behaviour, and if this is what you're looking for you may have to look elsewhere. Of course, if you have any ideas about how the button field module can incorporate values on the screen with the Rules module please let me know.

CinemaSaville’s picture

I tried the page redirect, and nothing happened. So I'm not sure if it's an issue with this module or rules. But essentially it should work upon pressing the button, right?

BassistJimmyJam’s picture

That's correct. Normally Rules are run during a page load, but this module uses ajax to fire the event. The ajax request returns a URL to redirect to (if any) then sets location.href to the URL. In a normal browser, that will redirect the page or open the users mail client if the link is a mailto. The same may not be true for a mobile browser. I will take a closer look at this when I have a chance.

CinemaSaville’s picture

Well it's not even working on the desktop browser. So I'm wondering where the issue could be. Maybe you could create a brief example on your site to show me that it works, and I'll then also access it with the mobile browser. Let me know if that wouldn't take too long. Thanks.

BassistJimmyJam’s picture

I have created a test page at http://www.jamesarmes.net/plugins/drupal/button_field/redirect. There is a button on this page that redirects to my email address and another that redirects to the homepage ('/'). I tested this in the following browsers on Windows Vista with Mozilla Thunderbird installed:

  • Google Chrome 3
  • Internet Explorer 8
  • Firefox 3.6
  • Opera 10
  • Safari 4

I also tested using the default browser on my BlackBerry Storm and had no issues.

CinemaSaville’s picture

OK, great, that works perfectly on my iPhone as well. So now we know that works. Just to be clear. Can you give me the exact steps of how you got that going?

Is it?:

1. Install and enable Button Field and Rules.
2. Add a Button Field to content type.
3. Create a rule where Button Field is the Event, the condition is Button Field simply "is", and the action is system- url redirect to path mailto:jimmyjam@jimmyjam.com

And can you give me the exact values you used in the page redirect action settings?

Thanks, Jimmy

CinemaSaville’s picture

Did it again, and absolutely nothing happens when I click the button. Although this may be connected to rules. I'm trying to delete rules, and they absolutely will not go away. Can't break these rules! Dammit. OK, I'll uninstall, and see what else I can do. Any tricks to doing this I should know?

BassistJimmyJam’s picture

StatusFileSize
new32.13 KB
new22.09 KB

I am using the latest dev version of Button Field and the latest stable version of Rules (6.x-1.1). See the attached screen shots for the settings for both the evaluation and action. Also, make sure you have the event set to "User Clicks a Button".

CinemaSaville’s picture

OK, I've installed the required versions of those modules. The event is set to "User Clicks a Button", and the action is set to page redirect with those settings, and the condition looks exactly like what you have. However, it's just not working. Nothing happens. And when I try to delete that rule, it doesn't get deleted. I've posted an issue in the rules issue queue, but no one has responded. So maybe my site is just not playing nice with rules. Don't know what else to try. Thanks so much for your help.

BassistJimmyJam’s picture

Title: I'm wondering if I can use this for a mobile mail form. » Sending email on mobile devices with a button field
Status: Active » Postponed (maintainer needs more info)

Please let me know whether or not you are able to track this back to the button field module. I would like to close this issue as soon as possible.

CinemaSaville’s picture

I don't think it's the button module, as the Rules module is the one acting funky. So you can seal up this issue if you like. Thanks for the effort. I wish I could get some love in the Rules issue queue, but nobody's responded to any of my queries.

BassistJimmyJam’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)
cazou’s picture

CinemaSaville, did you succeed in making a button from button_field work with rules ? I have the exact same problem, except that I can delete rules.

I noticed that when clicking the button, http://localhost/~cazou/drupal-6.19/button_field/callback?id=field_subsc...
was called, most certainly, by the AJAX system.

But I don't have a ~cazou/drupal-6.19/button_field/ directory on the server, am I supposed to ?
On BassistJimmyJam's button_field test page, there is a button_field directory.

Is that what's causing the problem ?

When I'm using another trigger (comment published for instance), everything works as expected.

cazou’s picture

Status: Closed (fixed) » Active

In fact, after checking network activity in wireshark, when the button is clicked, the AJAX request is sent and tries to GET /~detlev/drupal-6.19/button_field/callback?id=field_subscribe-8&path=%2F~detlev%2Fdrupal-6.19%2F HTTP/1.1\r\n
which answers with a 404 page not found...

Did I install the module wrong ? Is there any configuration to make ?

cazou’s picture

Well, I fixed it by modifying the js/button_field.js :

--- button_field/js/button_field.js     2010-06-06 03:56:52.000000000 +0200
+++ button_field/js/button_field.js.new 2010-12-01 05:19:12.587000053 +0100
@@ -2,9 +2,10 @@
 Drupal.behaviors.buttonFieldBehavior = function(context) {
   $('.button_field').bind('click', function() {
     $.ajax({
-      url: Drupal.settings.basePath+'button_field/callback',
+      url: Drupal.settings.basePath,
       dataType: 'json',
       data: {
+         q: 'button_field/callback',
          id: $(this).attr('id'),                                                                                                                                                
          path: location.pathname                                                                                                                                                
       },
BassistJimmyJam’s picture

@cazou, do you have clean URLs enabled?

BassistJimmyJam’s picture

Status: Active » Closed (cannot reproduce)

cazou's issue does not appear to be directly related to the topic of this thread, I have opened issue #1299758: Support unclean URLs in button field callback for this.