Přidání produktů do newsletteru
Následující dokument popisuje, jak přidat produkty do newslettrů.
Zkopírovat odkaz na sekciMail module modifikace
Nejprve je nutné upravit konfiguraci mail modulu.
- Přidat poskytovatele dat a freemarker-makra do šablony v mail modulu.
xml
1 <mailmodule>2 ...3 <superTemplate>4 <messageTemplate extends="default">5 ...6 <features>7 <freemarkerProcessing>8 <dataProviders>9 <dataProvider name="publishedProductMailProvider" bean="publishedProductMailProvider"/>10 </dataProviders>11 </freemarkerProcessing>12 </features>13 </messageTemplate>14 <dataProviders>15 <dataProvider name="publishedProductMailProvider" bean="publishedProductMailProvider"/>16 </dataProviders>17 <imports>18 <import>classpath:/META-INF/lib_eshop_edee/mail/mail-edeeshop-product-macros.ftl</import>19 </imports>20 </superTemplate>21 ...22</mailmodule>
- Přidat edee volbu na produkt, změňte TARGET_CATALOG na catalog na projektu, productKey je název proměnné, která poté bude přístupná ve ftl.
xml
1 <gui admin="true">2 <modifications>3 <modify target="defaultCampaignEditor">4 <appendWidget widget="emailDetails">5 <eshopProductTagsContainer id="eshopProductContainer">6 <metadata>7 <catalog>TARGET_CATALOG</catalog>8 <productKey>someKey</productKey>9 </metadata>10 </eshopProductTagsContainer>11 </appendWidget>12 </modify>13 </modifications>14</gui>
Přidání více selectů s různými katalogy se dá jednoduše změněním produktKey - pro odlišení proměnných ve ftl.
xml
1 <appendWidget widget="emailDetails">2 <eshopProductTagsContainer id="eshopProductContainer">3 <metadata>4 <catalog>TARGET_CATALOG</catalog>5 <productKey>someKey1</productKey>6 </metadata>7 </eshopProductTagsContainer>8 <eshopProductTagsContainer id="eshopProductCatalog2Container">9 <metadata>10 <catalog>TARGET_CATALOG2</catalog>11 <productKey>someKey2</productKey>12 </metadata>13 </eshopProductTagsContainer>14</appendWidget>
- Nakonec přidání titulků do module-mail/i18n (toto se odvíjí od id, která nastavíte widgetům). Např:
properties
1 eshopProductContainer.eshopProducts.title=E-shop produkty2eshopProductContainer.eshopProducts.allAvailableItems=Aktivní produkty v katalogu3eshopProductContainer.eshopProducts.allAvailableTags=Vybrat produkty
Zkopírovat odkaz na sekciFreemarker
V newsletter.ftl budou dostupné dvě proměnné (nastavené dle 2.) tedy př. someKey a someKey_catalog, který se předá do připraveného makra.
html
1 <#if someKey?has_content>2 <#assign productIds=someKey/>3 <@printProducts productCodes=productIds?split(",") catalogCode=someKey_catalog title="Novinky z eshopu"/>4</#if>
Zkopírovat odkaz na sekciExtra
V mail-edeeshop-product-macros.ftl je výčet nejčastěji používaných atributů.
Toto makro je možné na projektech přetížit a ostylovat dle svého, proměnné jsou již předané z newsletter.ftl a ostatní dle příkladu.
html
1 <#macro printProducts productCodes catalogCode title="">2 <#assign publishedProducts=publishedProductMailProvider.getProductsIndexedByCode(catalogCode, productCodes)/>3 4 <#if publishedProducts?size > 0>5 <table cellpadding="0" cellspacing="0" border="0" bgcolor="${texts.get('mail.config.emailBackgroundColor')}" style="margin-bottom: ${texts.get('mail.config.emailPaddingLarge')};" width="100%" align="center">6 <#if title!="">7 <tr>8 <td style="padding-bottom: ${texts.get('mail.config.emailPaddingMedium')};">9 <h2 style="font-size: ${texts.get('mail.config.emailTextLineHeight')};font-weight: ${texts.get('mail.config.emailBoldWeight')}; margin: 0!important;">${title}</h2>10 </td>11 </tr>12 </#if>13 <#list publishedProducts?values as product>14 <@printOneProduct product=product productIndex=product_index productHasNext=product?has_next/>15 </#list>16 </table>17 </#if>18</#macro>19 20<#macro printOneProduct product productIndex productHasNext>21 <#if (productIndex % 2) == 0>22 <tr>23 </#if>24 <td valign="top" width="50%">25 <table cellpadding="0" cellspacing="0" border="0" align="center">26 <tr>27 <td style="padding-bottom: ${texts.get('mail.config.emailPaddingMedium')}" align="center">28 <#assign mainMotive=product.mainMotive!/>29 <#assign mainMotiveUrl="/img/eshop/placeholder/eshop-mail-product-tiles.jpg"/>30 <#if mainMotive??><#assign mainMotiveUrl=(mainMotive.getUrl("eshop-mail-product-tiles"))!"/img/eshop/placeholder/eshop-mail-product-tiles.jpg"/></#if>31 <img src="${product.getAbsoluteUrlFromRelative(mainMotiveUrl)}" alt="${product.name!}" width="250" height="250" style="display: block;" border="0" />32 </td>33 <tr>34 <td style="padding-bottom: ${texts.get('mail.config.emailPaddingMedium')}" align="center">35 <h3 style="font-size: ${texts.get('mail.config.emailTextFontSizeLarge')}; font-weight: ${texts.get('mail.config.emailBoldWeight')}; margin: 0!important;">${product.name!}</h3>36 </td>37 </tr>38 <#if product.descriptionShort??>39 <tr>40 <td style="padding-bottom: ${texts.get('mail.config.emailPaddingMedium')}" align="center">41 ${product.descriptionShort!}42 </td>43 </tr>44 </#if>45 <#if product.sellingPrice?has_content>46 <tr>47 <td style="padding-bottom: ${texts.get('mail.config.emailPaddingMedium')}" align="center">48 <h3 style="font-size: ${texts.get('mail.config.emailTextFontSize')}; margin: 0!important; font-weight: ${texts.get('mail.config.emailBoldWeight')};">${texts.convertToText(eshop.formatPrice(product.sellingPrice.priceWithTax(), product.sellingPrice.currency(), "price.zeroPriceString"))}</h3>49 </td>50 </tr>51 </#if>52 <tr>53 <td align="center" style="padding-bottom: ${texts.get('mail.config.emailPaddingLarge')}">54 <table border="0" cellspacing="0" cellpadding="0">55 <tr>56 <td align="center" style="border-radius: ${texts.get('mail.config.emailBtnBorderRadius')};" bgcolor="${texts.get('mail.config.emailBtnBackgroundColor')}">57 <a href="${product.absoluteUrl}" class="btn" target="_blank" style="font-size: ${texts.get('mail.config.emailTextFontSizeSmaller')}; color: ${texts.get('mail.config.emailBtnTextColor')}!important; text-decoration: none; padding: ${texts.get('mail.config.emailBtnPadding')}; display: inline-block;">${texts.get("edeeShop.mail.tile.detail")}</a>58 </td>59 </tr>60 </table>61 </td>62 </tr>63 </table>64 </td>65 <#if ((productIndex % 2) == 1) || (!productHasNext)>66 </tr>67 </#if>68</#macro>