TB.One > Product and Article Data > Templates > Creating Twig Templates > EXAMPLE TWIG TEMPLATE

EXAMPLE TWIG TEMPLATE

<!-- Define headline, here with prefix + common noun + proper name, display split variants where applicable -->

<h1>{{ product.prefix }} {{ product.name_keyword }} {{ product.name_proper }}

{% if not product.split_variations is empty %}

({{ product.split_variations | join(", ") }})

{% endif %}

{% if not product.variation_values is empty %}

{{ product.variation_values | join(", ") }}

{% endif %}

</h1>

<!-- Display product number -->

Produktnummer: {{ product.p_nr }}

<!-- Insert special text (if any exists) -->

{% if not product.supplement is empty %}

<h2>{{ product.supplement }}</h2>

{% endif %}

<!-- Format display -->

<table width="100%" cellpadding="0" cellspacing="0" >

<tr>

<td width="1%" valign="top"><img src="http://server.net/img/blind.gif" /></td>

<td width="30%" valign="top" align="center">

<!-- Include media. The parameter  eps_url is only valid for eBay. -->

{% if channel.short_name == "ebde" %}

{% for row in media %}

<img src="{{ row | eps_url(10) }}" />

{% endfor %}

{% endif %}

</td>

<td width="69%" valign="top" align="left" cellpadding="2">

<!-- Insert brand (if not used as a prefix) -->

<p>Stylishe {{ product.name_keyword }} von <strong>{{ product.brand.name }}</strong></p>

<!-- Insert product description with line breaks -->

<p>{{ product.text | nl2br }}</p>

<!-- Insert navigation -->

<p>

{% for category in product.channel_data.ebde.categories %}

<!-- tbone id -->

{{ category.id }}

<!-- eBay category id -->

{{ category.key }}

<!-- Path -->

{{ category.name }}

<!-- primary or secondary category -->

{{ category.type }}

{% endfor %}

</p>

<!-- List components (if any exist). The formatted as a bullet list but every other format is possible, too -->

<p>

{% if not product.comps_all is empty %}

{% for component in product.comps_all %}

{{ component.key }}: {{ component.value }}

{% endfor %}

{% endif %} 

</p>

<!-- List product attributes -->

<p>

<ul>

{% for tag in product.tags %}

<li><span>{{ tag.name }}</span>:

<ul>

{% for value in tag.values %}

<li>{{ value.name }}</li> 

{% endfor %}

</ul>

{% endfor %}

</li>

</ul> 

</p>

<!-- List bullet points (if any exist) -->

<p>

{% if not product.text_bullets is empty %}

<ul>

{% for item in product.text_bullets %}

<li>{{ item }}</li>

{% endfor %}

</ul>

{% endif %}

<!-- Insert feature list (if one exists)-->

{% if not product.text_features is empty %}

<ul>

{% for item in product.text_features %}

<li>{{ item }}</li>

{% endfor %}

</ul>

{% endif %}

</p>

<!-- Insert service text (if it exists) -->

<p>

{% if not product.text_service is empty %}

<strong>Servicehinweis:</strong>{{ product.text_service | nl2br }}

{% endif %}

</p>

<!-- Insert environmental text (if it exists) -->

<p>

{% if not product.text_environmental is empty %}

<strong>Umwelthinweis:</strong>&nbsp;{{ product.text_environmental | nl2br }}

{% endif %}

</p>

<!-- If RP is lower than MSRP, display MSRP (formatted to 2 decimal places) -->

{% set lowestMAPprice = null %}

{% for article in product.articles %}

{% if (article.a_uvp > article.a_vk) and ((lowestMAPprice == null) or (lowestMAPprice > article.a_uvp)) %}

{% set lowestMAPprice = article.a_uvp %}

{% endif %}

{% endfor %}

{% if (lowestMAPprice != null) %}

<p>UVP<span>&nbsp; {{ lowestMAPprice | number_format(2, ',', '.') }} &euro;&nbsp;</span></p>

{% endif %}

<!-- If RP is lower than former RP, display former RP (formatted to 2 decimal places) -->

{% set lowestOldprice = null %}

{% for article in product.articles %}

{% if (article.a_vk_old > article.a_vk) and ((lowestOldprice == null) or (lowestOldprice > article.a_vk_old)) %}

{% set lowestOldprice =  article.a_vk_old %}

{% endif %}

{% endfor %}

{% if (lowestOldprice != null) %}

<p class="uvp">Vorher <span>&nbsp; {{ lowestOldprice | number_format(2, ',', '.') }} &euro;&nbsp;</span></p>

{% endif %}

<!-- Calculate and display lowest price. To do this, set the variable value is set to zero first. -->

{% set lowestprice = null %}

{% for article in product.articles %}

{% if (lowestprice == null) or (lowestprice > article.a_vk) %}

{% set lowestprice = article.a_vk %}

{% endif %}

{% endfor %}

<p class="articlePrice"><strong>jetzt nur noch</strong> &euro; {{ lowestprice | number_format(2, ',', '.') }}</p>

<!-- Calculate max VAT rate across all articles -->

{% set tax = null %}

{% for article in product.articles %}

{% if (article.a_tax > tax) %}

{% set tax = article.a_tax %}

{% endif %}

{% endfor %}

<!-- Calculate max. shipping costs across all articles -->

{% set shipping = null %}

{% for article in product.articles %}

{% if (article.delivery.shipping_costs > shipping) %}

{% set shipping = article.delivery.shipping_costs %}

{% endif %}

{% endfor %}

<!-- Display VAT and shipping costs for the product (formatted to 2 decimal places) -->

<p>

{% if (shipping != 0) %}

incl. {{ tax }} % VAT plus {{ shipping | number_format(2, ',', '.') }} &euro; shipping costs.

{% else %}

incl. {{ tax }} % VAT <strong>free shipping</strong>

{% endif %}

</p>

<!-- Calculate max. weight for all articles -->

{% set weight = null %}

{% for article in product.articles %}

{% if (article.packaging.weight > weight) %}

{% set weight = article.packaging.weight %}

{% endif %}

{% endfor %}

<p>Gewicht: {{ weight }}&nbsp;kg </p>

<!-- calculate max. delivery time across all articles -->

{% set time = null %}

{% for article in product.articles %}

{% if (article.delivery.time > time) %}

{% set time = article.delivery.time %}

{% endif %}

{% endfor %}

<p>Lieferzeit: {{ time }}&nbsp;Tag(e) </p>

<!--Identify replaceability flag for all articles-->

<!-- The flag replaceability should normally not be displayed but may be used to calculate the delivery time of an article. For example, if the flag is 1, the delivery.time + delivery.replace_time are calculated to show the correct shipping time if stock is 0 -->

{% set replace = null %}

{% for article in product.articles %}

{% if (article.delivery.replace > replace) %}

{% set replace = article.delivery.replace %}

{% endif %}

{% endfor %}

<p>Wiederbeschaffbar: {{ replace }}</p>

<!-- Max. Replenishment lead time (= time until as sold out article is available again) for all items --> 

{% set repl_time = null %}

{% for article in product.articles %}

{% if (article.delivery.replace_time > repl_time) %}

{% set repl_time = article.delivery.replace_time %}

{% endif %}

{% endfor %}

<p>Wiederbeschaffungszeit: {{ repl_time }}&nbsp;Tag(e) </p>

</td>

</tr>

</table>

<!-- Insert article information -->

<p><strong>Varianteninformationen:</strong></br>

<!-- Writes the table head -->

<table border="1" align="left">

<tr>

<th>Art.No:</th>

<th>Art.No2:</th>

<th>Hersteller-Art.No.:</th>

<th>EAN:</th>

<th>Bestand:</th>

<th>Maße:</th>

</tr>

<!-- Writes the dynamic part of the table-->

{% for article in product.articles %}

<tr>

<!-- Article number -->

<td>{{ article.a_nr }}</td>

<!-- Article number 2 -->

<td>{{ article.a_nr2 }} </td>

<!-- Product number for the article's parent product -->

<td>{{ article.a_prod_nr }} </td>

<!-- EAN -->

<td>{{ article.a_ean }} </td>

<!-- Stock -->

<td>{{ article.a_stock }} </td>

<!-- Package width x length x height-->

<td>{{ article.packaging.width }}&nbsp;cm x {{ article.packaging.length }}&nbsp;cm x {{ article.packaging.height }}&nbsp;cm </td>

</tr>

{% endfor %}

</table>

</p>

<!-- Insert cross-selling links if any exist (only eBay)  -->

{% if channel.short_name == "ebde" %}

{% set fittingArticles=[] %}

{% set links=product|collect_ebay_links(8) %}

{% if not links is empty %}

<div>

<h2>Further Recommendations</h2>

{% for link in links %}

{% set fittingArticles=fittingArticles|merge([link.target.p_nr]) %}

{% endfor %}

</div>

{% endif %}

{% endif %}