My website is on Drupal.
We have preformatted Mosaico templates with header (view in your browser) and footer (social media buttons, organizational address, and unsubcribe options) in English.
HOWEVER, we do many identical mailings in 3 languages. It is simplest to copy the English mailing, then switch out the text to French and Spanish, rather than recreate the mailing from scratch using a French or Spanish.
But, this means i have to copy and paste French or Spanish text into the header and footer EVERY time.
It seems to me I should be able to save a custom block with my footer in Fr and another with footer in Sp to drop into a mailing.
But how?
(Or, another solution to my problem, I guess, would be a better photo gallery, so I could just use the "make a french template" option. The absolutely wretchedness of the ridiculously inadequate photo gallery is part 1 of what makes me choose copying and pasting all the fr and sp text into the original english draft so as not to have to deal with photos again, rather than recreating a draft on a Fr or Sp template. How does this program have the worst photo gallery imaginable? Part 2 is the huge amount of white space in the template that makes it impossible to see the end of a long link. [the number of times I've sent a messed up link because I can't see what I've pasted there...(fist shaking)!!])
-
I am curious: did you do the extension or did you follow the recommendation of @ChumKui? Can you post here your solution? So it might be useful to me and others.– masettoCommented Aug 2, 2022 at 14:06
-
My technical skills are low so I did not try configuring anything myself. I have started using the traditional templates more. A developer configured the header and footer sections with required tokens in all 3 languages, so that has simplified that part.– user7955Commented Aug 5, 2022 at 22:28
1 Answer
It is possible to define custom blocks to mosaico templates. To do this, you have to create an extension that provides a custom base template and implements the hook_civicrm_mosaicoBaseTemplates hook to register your template. In your custom base templates you can define custom blocks. I found these tutorials useful for understanding how the mosaico blocks work.
- https://github.com/voidlabs/mosaico/blob/master/templates/tutorial/mosaico-tutorial.md
- https://github.com/voidlabs/mosaico/wiki/Template-language
I think you should start creating your base templates from the one you are currently using. So copy it to your extension. Then edit the html file, duplicate the header and footer blocks, rename them to prevent issues from the duplicated block names. In the duplicates you can add text in different languages. Repeat from the duplication for the third language. Now you have the blocks, but the thumbnail images are missing for them. There is a script in the versafix template repo that could be used for generating the thumbnails for your template. This script needs to be modified a little bit, but you can execute it to generate the images for your template. The generated main image for your custom template could be too similar to the main image of template that you copied before. For making them distinguishable you can add a watermark or some text to the generated image called _full.png
-
Creating your own blocks is not for the fainthearted - take a look at this blog post by ArfulRobot: artfulrobot.uk/blog/… . You can avoid using an extension by copying an existing template into your mosaico_tpl folder. See post here: civicrm.stackexchange.com/a/42288/6361– ChumKuiCommented Jul 14, 2022 at 16:03