0

I am using Simple HTML Message as the Template to create my email. Layout is Text Message Layout. It is not allowing to add components, Images or internal Links.

This could be an issue of layout, if I only want to create a new Layout for email, so that the rendering and images and internal links can be added, How do I achieve that.

Can anyone provide a sample cshtml for the layout.

Thanks

2

Creating a Layout for EXM is not much different from creating the layout for your normal Sitecore item, To create the layout of your message template:

Step 1: Create Layout in Sitecore

  • In the Content Editor, navigate to /sitecore/Layout/Layouts/System/Email/ and insert a new layout, for example, NewsletterLayout.

enter image description here

Notice, we have passed the view layout path, that we will create in step 2.

Step 2: Create Layout view file in solution

  • Now in your solution, create a razor view file eg. NewsletterLayout.cshtml,
@using Sitecore.Mvc
@using Sitecore.Mvc.Presentation

@model RenderingModel
<html style="opacity: 1;" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <meta content=" width=device-width, initial-scale=1, maximum-scale=1" name="viewport" />
    <meta content="IE=edge" http-equiv="X-UA-Compatible" />
    @Html.Sitecore().Placeholder("msg-html-title")
    @Html.Sitecore().Placeholder("msg-html-style")
</head>
<body>
    <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody>
            <tr>
                <td align="center">
                    @Html.Sitecore().Placeholder("newsletter-header")
                    @Html.Sitecore().Placeholder("newsletter-body")
                    @Html.Sitecore().Placeholder("footer")

                </td>
            </tr>
        </tbody>
    </table>
</body>
</html>

Step 3: Branch Templates and Data Templates in Sitecore

  • Now you need to create a new branch template or you can duplicate the existing ones from this path: Templates/Branches/System/Email/Messages

enter image description here

  • Assign your custom layout on Message Root. enter image description here

  • Create a new data template at Templates/System/Email/Messages/Inner Content and add the required field to this template.

enter image description here

Refer to this blog for more details.

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.