Answers.Body: <p>It is possible to define custom blocks to mosaico templates. To do this, you have to create an extension that provides a custom <a href="https://docs.civicrm.org/mosaico/en/latest/api/#base-templates" rel="nofollow noreferrer">base template</a> 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.</p>
  <ul>
  <li><a href="https://github.com/voidlabs/mosaico/blob/master/templates/tutorial/mosaico-tutorial.md" rel="nofollow noreferrer">https://github.com/voidlabs/mosaico/blob/master/templates/tutorial/mosaico-tutorial.md</a></li>
  <li><a href="https://github.com/voidlabs/mosaico/wiki/Template-language" rel="nofollow noreferrer">https://github.com/voidlabs/mosaico/wiki/Template-language</a></li>
  </ul>
  <p>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 <a href="https://github.com/voidlabs/versafix-template/blob/master/src/makeThumbs.js" rel="nofollow noreferrer">script</a> in the versafix template repo that could be used for generating the thumbnails for your template. <a href="https://github.com/voidlabs/versafix-template/blob/master/src/index.js" rel="nofollow noreferrer">This</a> 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 <a href="https://github.com/voidlabs/versafix-template/blob/master/dist/template/edres/_full.png" rel="nofollow noreferrer">_full.png</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-14T16:03:37.123Z
Answers.Text: Creating your own blocks is not for the fainthearted - take a look at this blog post by ArfulRobot: https://artfulrobot.uk/blog/adding-custom-block-mosaico-email-editor-civicrm#comment-4252 . You can avoid using an extension by copying an existing template into your mosaico_tpl folder.  See post here: https://civicrm.stackexchange.com/a/42288/6361
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-10T10:17:03.967Z
Answers.LastActivityDate: 2021-07-10T10:17:03.967Z
Answers.UserDisplayName: akosgarai
Body: <p>My website is on Drupal. <br>
  We have preformatted Mosaico templates with header (view in your browser) and footer (social media buttons, organizational address, and unsubcribe options) in English. <br>
  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.<br>
  But, this means i have to copy and paste French or Spanish text into the header and footer EVERY time. <br>
  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. <br>
  But <strong>how</strong>?<br>
  (Or, another solution to my problem, I guess, would be a better photo gallery, so I could just use the &quot;make a french template&quot; 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 <strong>can't see</strong> what I've pasted there...(fist shaking)!!])</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-02T14:06:16.317Z
Comments.Text: 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.
Comments.UserDisplayName: masetto
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-05T22:28:35.633Z
Comments.Text: 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.
Comments.UserDisplayName: user7955
Tags: <email><mosaico><custom-templates>
Title: Create customized "block" in Mosaico
ThreadText: # Create customized "block" in Mosaico
  
  (Asked by: username_0 on 2021-07-09)
  
  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)!!])
  
  **Tags:** email, mosaico, custom-templates
  
  > **Comments:**
  > **username_1**: I am curious: did you do the extension or did you follow the recommendation of @username_3? Can you post here your solution? So it might be useful to me and others.  
  > **username_0**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-07-10. Score: 3
  
  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](https://docs.civicrm.org/mosaico/en/latest/api/#base-templates) 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](https://github.com/voidlabs/versafix-template/blob/master/src/makeThumbs.js) in the versafix template repo that could be used for generating the thumbnails for your template. [This](https://github.com/voidlabs/versafix-template/blob/master/src/index.js) 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](https://github.com/voidlabs/versafix-template/blob/master/dist/template/edres/_full.png)
  
  > **Comments:**
  > **username_3**: Creating your own blocks is not for the fainthearted - take a look at this blog post by ArfulRobot: https://artfulrobot.uk/blog/adding-custom-block-mosaico-email-editor-civicrm#comment-4252 . You can avoid using an extension by copying an existing template into your mosaico_tpl folder.  See post here: https://civicrm.stackexchange.com/a/42288/6361  
  
  ---
  
  