Preheader in custom template

kosir

Member
Hello,

I created a custom template and everything except preheader is showing. I am using the preheader field but it's not added to my emails.

My question, how can I add text from preheader field to my template? It's not listed under available tags.
 
@kosir - the preheader isn't shown in the email template. The preheader is used for when the emails is viewed in the email client, before it is clicked, to show a small excerpt about the email content.
 
Hey,

Yes, but it must be somehow added to the email source/original.
Right now the first line of my email is displayed where preheader should be in gmail. Even if i look at the source preheader is not there.
So there must be some tag that I must add to the template so the preheader will be added.
 
@kosir - mailwizz tries to inject that right after the opening <body> tag, so you must have a body tag and a head tag:
PHP:
/**
* @param $emailContent
* @param $preheader
* @param Campaign $campaign
* @return mixed
*/
public static function injectPreheader($emailContent, $preheader, Campaign $campaign)
{
    $hideCss      = 'display:none!important;mso-hide:all;';
    $style        = sprintf('<style type="text/css">span.preheader{%s}</style>', $hideCss);
    $emailContent = str_ireplace('</head>', $style . '</head>', $emailContent);
    $preheader    = sprintf('<span class="preheader" style="%s">%s</span>', $hideCss, $preheader);
    return preg_replace('/<body([^>]+)?>/six', '$0' . $preheader, $emailContent);
}
 
Back
Top