@@ -57,8 +57,8 @@ public function exportTemplate(Document\PageSnippet $document)
5757 $ html = Mail::setAbsolutePaths ($ html , $ document );
5858
5959 //dirty hack to make sure mailchimp merge tags are not url-encoded
60- $ html = str_replace (' *%7C ' , ' *| ' , $ html );
61- $ html = str_replace (' %7C* ' , ' |* ' , $ html );
60+ $ html = str_replace (" *%7C " , " *| " , $ html );
61+ $ html = str_replace (" %7C* " , " |* " , $ html );
6262
6363 $ templateExists = false ;
6464
@@ -70,30 +70,32 @@ public function exportTemplate(Document\PageSnippet $document)
7070 }
7171 }
7272
73+ $ templateName = substr ($ document ->getKey (), 0 , 35 ) . ' [ID ' . $ document ->getID () . '] ' ;
74+
7375 if ($ remoteId && $ templateExists ) {
7476 $ this ->getLogger ()->info (
7577 sprintf (
7678 '[MailChimp] Updating new Template with name %s based on document id %s ' ,
77- $ document -> getFullPath () ,
79+ $ templateName ,
7880 $ document ->getId ()
7981 )
8082 );
8183
8284 $ result = $ apiClient ->patch ("templates/ $ remoteId " , [
83- 'name ' => $ document -> getFullPath () ,
85+ 'name ' => $ templateName ,
8486 'html ' => $ html
8587 ]);
8688 } else {
8789 $ this ->getLogger ()->info (
8890 sprintf (
8991 '[MailChimp][Template] Creating new template with name %s based on document id %s ' ,
90- $ document -> getFullPath () ,
92+ $ templateName ,
9193 $ document ->getId ()
9294 )
9395 );
9496
9597 $ result = $ apiClient ->post ('templates ' , [
96- 'name ' => $ document -> getFullPath () ,
98+ 'name ' => $ templateName ,
9799 'html ' => $ html
98100 ]);
99101 }
@@ -106,7 +108,7 @@ public function exportTemplate(Document\PageSnippet $document)
106108 $ this ->getLogger ()->error (
107109 sprintf (
108110 '[MailChimp][Template] Failed to export template %s: %s %s ' ,
109- $ document -> getFullPath () ,
111+ $ templateName ,
110112 json_encode ($ apiClient ->getLastError ()),
111113 $ apiClient ->getLastResponse ()['body ' ]
112114 ),
0 commit comments