3

When attempting to reuse a mail, things work normally until clicking 'Edit' which results in a mostly blank page - some of the Mosaico page is shown but not the content.

What turns out to be important is that the site recently moved from using http:// to https://

1
  • I've answered a more general version of your question below.
    – Alan Dixon
    Nov 6, 2019 at 15:19

3 Answers 3

4

If you change your site's domain, the specific sql that you can run to fix your templates and (separately) your existing messages (e.g. those in progress or in case you want to copy them):

From "olddomain.org" to "newdomain.org":

update civicrm_mosaico_template set metadata = replace(metadata,'olddomain.org','newdomain.org');
update civicrm_mailing set template_options = replace(template_options,'olddomain.org','newdomain.org');

If your old/new domains share some parts (e.g. you're going from domain.org to www.domain.org) you'll want to be careful not to run it more than once and it may mess up something else.

If you're also changing the protocol (http to https), then it's a bit tricky because the template_options field is in json notation with "/" escaped. You could do it in a separate step, replacing 'http' with 'https' for example.

There's an open issue here: https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/issues/87 to try and fix it.

1
  • If you're using this to update the path (i.e. if you've moved the location of your extension) then you'll need to know that the paths are being escaped with backslashes in the json in the db, and the mysql replace function handles backslashes in a confusing and badly documented way. My cheatsheet summary is: use double backslashes in the from, no escaping in the to, e.g. update civicrm_mailing set template_options = replace(template_options,'\\/vendor\\/uk.co.vedaconsulting.mosaico','\/sites\/default\/files\/civicrm\/ext\/uk.co.vedaconsulting.mosaico');
    – Alan Dixon
    Jul 19, 2021 at 15:41
4

Using the browser network tools shows a failure to load the template with a "mixed content" message. The problem is that the template metadata includes the full URL of the template.

The fix is to update the template URL in the Mosaico metadata to use https:// in place of http://

With db access, you can update template_options in civicrm_mailing.

Alternatively, start from cv api Mailing.get id=...

Update

There is now an API call to update the templates for you. See the docs

cv api MosaicoTemplate.replaceurls from_url="http://old.server.org" to_url="https://new.server.org"
0

I had the same issue when creating a new mailing when I migrated a site from Drupal to WordPress, so obviously the path changed. Correcting the path in the Metadata field in the civicrm_mosaico_template table fixed it for me. However, to be able to reuse old mailings, I did have to use the method above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.