Hi,

I got chance to work with mailchimp module recently. I must say it is a good module.
In order to make it more interesting in user experience view, I recommend a send button link while user is viewing all campaigns at mailchimp/campaigns page. Attached image can provide more details.

Comments

pranavpathak’s picture

In order to add Send link option at mailchimp/campaigns page you can use below code in mailchimp_campaign.module file.

diff --git a/modules/mailchimp_campaign/mailchimp_campaign.module b/modules/mailchimp_campaign/mailchimp_campaign.module
index 4805980..fca034c 100644
--- a/modules/mailchimp_campaign/mailchimp_campaign.module
+++ b/modules/mailchimp_campaign/mailchimp_campaign.module
@@ -210,11 +210,24 @@ function mailchimp_campaign_overview_page() {
   $rows = array();
   foreach ($campaigns as $campaign) {
     $actions = array(
-      l(t('View Archive'), $campaign->mc_data['archive_url'], array(
-        'attributes' => array('target' => '_blank'),
-      )),
-      l(t('View'), 'admin/config/services/mailchimp/campaigns/' . $campaign->mc_campaign_id),
-    );
+                       if($campaign->mc_data['status'] == 'save'){
+                               $actions = array(
+                                       l(t('View Archive'), $campaign->mc_data['archive_url'], array(
+                                               'attributes' => array('target' => '_blank'),
+                                       )),
+                                       l(t('View'), 'admin/config/services/mailchimp/campaigns/' . $campaign->mc_campaign_id)
+                                       l(t('Send'),'admin/config/services/mailchimp/campaigns/' . $campaign->mc_campaign_id .
+                               );
+                       }
+                       else{
+                               $actions = array(
+                                       l(t('View Archive'), $campaign->mc_data['archive_url'], array(
+                                               'attributes' => array('target' => '_blank'),
+                                       )),
+                                       l(t('View'), 'admin/config/services/mailchimp/campaigns/' . $campaign->mc_campaign_id)
+                               );
+                       }
+               );
pranavpathak’s picture

Assigned: pranavpathak » Unassigned
jami’s picture

Version: 7.x-3.2 » 7.x-3.x-dev
Status: Active » Needs work

Hi pranavpathak. I think this is a good usability improvement, but it needs logic to check whether the campaign can be sent, and I'm currently prioritizing issues that are ready to ship. If you have time to add that logic, I can take another look.

You may already be familiar with these instructions and (understandably!) in a hurry, but it's easier to review and apply patches if they're submitted in the format described here:
https://www.drupal.org/patch/submit

Thank you for the code -- I do like having that Send link there!

pranavpathak’s picture

StatusFileSize
new11.19 KB
new1.36 KB

Hi @Jami,

Thanks for your reply.
I am not export to create a patch file. However I tried.
Attached patch file is MailChimp-Needlink-2456469-1.patch and result will looks like mailchimp-patch-result.png.
Please let me know if I am wrong somewhere.

pranavpathak’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: MailChimp-Needlink-2456469-1.patch, failed testing.

pranavpathak’s picture

StatusFileSize
new1.39 KB

Issue is updated and solved, updated patched is attached called MailChimp-Needlink-2456469-2.patch .

pranavpathak’s picture

Status: Needs work » Needs review
eojthebrave’s picture

Status: Needs review » Needs work

This seems like a great feature addition.

I have a couple of thoughts on the latest patch.

1st. Drupal coding standards calls for the use of spaces (2x of them) instead of tabs for code indentation. So we should fix that.

Second. I looks like you can reduce some duplication in your code by building the links that are always present first, and then just adding the send link on to the end if it's appropriate. Pseudo code:

$links[] = 'view archive link';
$links[] = 'view link';

if ($can_send) {
  $links[] = 'send link';
}
pranavpathak’s picture

StatusFileSize
new1.17 KB

Hi @eojthebrave,

Patch file MailChimp-Needlink-2456469-3.patch is updated as per the instruction in #9.

pranavpathak’s picture

Status: Needs work » Needs review
eojthebrave’s picture

Status: Needs review » Needs work
+++ b/modules/mailchimp_campaign/mailchimp_campaign.module
@@ -209,12 +209,15 @@ function mailchimp_campaign_overview_page() {
+		$actions[] = l(t('View Archive'), $campaign->mc_data['archive_url'], array( 'attributes' => array('target' => '_blank'),));
+    $actions[] = l(t('View'), 'admin/config/services/mailchimp/campaigns/' . $campaign->mc_campaign_id);

This line still has extra whitespace. But otherwise this looks good to me. I haven't actually tested the patch but the code looks good, and I think this is a good feature to add.

pranavpathak’s picture

StatusFileSize
new6.3 KB

Hi,
New patch file is created called MailChimp-Needlink-2456469-4.patch, Apologies for whitespace error.
Kindly ignore #13 patch file and please read #15 patch file.

pranavpathak’s picture

Status: Needs work » Needs review
pranavpathak’s picture

StatusFileSize
new1.17 KB
eojthebrave’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. Thanks @pranavpathak for both the awesome patch and for putting up with me being picky about whitespace.

  • levelos committed 082f04b on
    Merge pull request #162 from thinkshout/send-link-in-campaign-list...
  • jami committed 649aabf on
    Issue #2456469 by pranavpathak,eojthebrave: Send link on campaign list.
    
jami’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Added the commit. Thanks for your work, pranavpathak and eojthebrave!

pranavpathak’s picture