<{assign var="strip_classes" value=$strip_classes|default:true}> <{assign var="headline_conversion" value=$headline_conversion|default:true}> <{* Remove empty paragraphs *}> <{assign var="pattern" value="/\ \<\/p\>/"}> <{assign var="replacement" value=""}> <{assign var="content" value=$content|regex_replace:$pattern:$replacement}> <{* Remove style-tags *}> <{assign var="pattern" value="/ style=\"(.*?)\"/"}> <{assign var="replacement" value=""}> <{assign var="content" value=$content|regex_replace:$pattern:$replacement}> <{* Remove style-tags *}> <{if $strip_classes}> <{assign var="pattern" value= "/ class=\"(.*?)\"/"}> <{assign var="replacement" value=""}> <{assign var="content" value=$content|regex_replace:$pattern:$replacement}> <{/if}> <{* Convert headlines *}> <{if $headline_conversion}> <{assign var="pattern" value="/\/"}> <{assign var="replacement" value="

"}> <{assign var="content" value=$content|regex_replace:$pattern:$replacement}> <{assign var="pattern" value="/\<\/h1(.*?)\>/"}> <{assign var="replacement" value="

"}> <{assign var="content" value=$content|regex_replace:$pattern:$replacement}> <{/if}> <{* Replace [terms_trade] with the value of $terms_trade *}> <{if preg_match_all('/\[terms_trade\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{assign var="terms_trade" value=$settings.terms.trade}> <{assign var="content" value=$content|replace:$match:$terms_trade}> <{/foreach}> <{/if}> <{* Replace [terms_gdpr] with the value of $terms_gdpr *}> <{if preg_match_all('/\[terms_gdpr\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{assign var="terms_gdpr" value=$settings.terms.gdpr}> <{assign var="content" value=$content|replace:$match:$terms_gdpr}> <{/foreach}> <{/if}> <{* Replace [terms_eprivacy] with the value of $terms_eprivacy *}> <{if preg_match_all('/\[terms_eprivacy\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{assign var="terms_eprivacy" value=$settings.terms.eprivacy}> <{assign var="content" value=$content|replace:$match:$terms_eprivacy}> <{/foreach}> <{/if}> <{* Replace [terms_return] with the value of $terms_return *}> <{if preg_match_all('/\[terms_return\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{assign var="terms_return" value=$settings.terms.return}> <{assign var="content" value=$content|replace:$match:$terms_return}> <{/foreach}> <{/if}> <{* Replace [terms_payment] with the value of $terms_payment *}> <{if preg_match_all('/\[terms_payment\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{assign var="terms_payment" value=$settings.terms.payment}> <{assign var="content" value=$content|replace:$match:$terms_payment}> <{/foreach}> <{/if}> <{* Replace [terms_delivery] with the value of $terms_delivery *}> <{if preg_match_all('/\[terms_delivery\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{assign var="terms_delivery" value=$settings.terms.delivery}> <{assign var="content" value=$content|replace:$match:$terms_delivery}> <{/foreach}> <{/if}> <{* Replace [image href="https://mydomain.com/images/image-1.jpg"] with a image from the URL *}> <{if preg_match_all('/\[image\s+href="([^"]+)"\]/', $content, $matches)}> <{if $template}> <{foreach from=$matches[0] item=$match}> <{if preg_match('/href="([^"]+)"/', $match, $ids)}> <{foreach from=$ids[1] item=$occurance}> <{capture name="image"}> <{include file="components/image.html" href=$occurance class="" padding="none" aspect_ratio="auto" aspect="auto"}> <{/capture}> <{assign var="content" value=$content|replace:$match:$smarty.capture.image}> <{/foreach}> <{/if}> <{/foreach}> <{/if}> <{/if}> <{* Replace [image index="1"] with a image from the post with same index *}> <{if preg_match_all('/\[image index="([\d,\s]+)"\]/', $content, $matches)}> <{if $template}> <{assign var="images" value=$template->getImages()}> <{foreach from=$matches[0] item=$match}> <{if preg_match('/index="([\d,\s]+)"/', $match, $ids)}> <{foreach from=$ids[1] item=$occurance}> <{assign var="image" value=$images[$occurance-1|intval]}> <{if $image}> <{capture name="image"}>
<{include file="components/image.html" class="" padding="none" aspect_ratio="auto" aspect="auto" width=$image->getWidth() height=$image->getheight() image=$image type="webp"}>
<{$image->getDescription()}>
<{/capture}> <{assign var="content" value=$content|replace:$match:$smarty.capture.image}> <{/if}> <{/foreach}> <{/if}> <{/foreach}> <{/if}> <{/if}> <{* Replace [youtube_embed id="1234"] with a html-embed *}> <{if preg_match_all('/\[youtube_embed id="([\w-]+)"\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{if preg_match('/id="([\w-]+)"/', $match, $ids)}> <{foreach from=$ids[1] item=$occurance}> <{capture name="embed"}> <{/capture}> <{/foreach}> <{assign var="content" value=$content|replace:$match:$smarty.capture.embed}> <{/if}> <{/foreach}> <{/if}> <{* Replace [products ids="1,2,3" columns="5" max="10"] with a product grid *}> <{if preg_match_all('/\[products ids="([\d,\s]+)"(?: columns="([\d]+)")?(?: max="([\d]+)")?\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{if preg_match('/ids="([\\d,]+)"/', $match, $ids)}> <{foreach from=$ids[1] item=$occurance}> <{assign var="product_ids" value=","|explode:$occurance}> <{capture name="product_grid"}> <{assign var="columns" value=$matches[2][0]|default:'4'}> <{assign var="max" value=$matches[3][0]|default:'4'}> <{/capture}> <{assign var="content" value=$content|replace:$match:$smarty.capture.product_grid}> <{/foreach}> <{/if}> <{/foreach}> <{/if}> <{* Replace [products category="2626863" columns="5" max="10"] with a product grid *}> <{if preg_match_all('/\[products category="([\d]+)"(?: columns="([\d]+)")?(?: max="([\d]+)")?\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{capture name="product_grid"}> <{assign var="category_id" value=$matches[1][0]}> <{if $category_id}> <{assign var="category" value=$webshop->getCategory($category_id)}> <{if $category}> <{assign var="columns" value=$matches[2][0]|default:'4'}> <{assign var="max" value=$matches[3][0]|default:'4'}> <{assign var="products" value=$category->getOnlineProducts( $max )}> <{/if}> <{/if}> <{/capture}> <{assign var="content" value=$content|replace:$match:$smarty.capture.product_grid}> <{/foreach}> <{/if}> <{* Replace [products landingpage="2626863" columns="5" max="10"] with a product grid *}> <{if preg_match_all('/\[products landingpage="([\d]+)"(?: columns="([\d]+)")?(?: max="([\d]+)")?\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{capture name="product_grid"}> <{assign var="landingpage_id" value=$matches[1][0]}> <{if $landingpage_id}> <{assign var="landing_page" value=$webshop->getLandingPage($landingpage_id)}> <{if $landing_page}> <{assign var="columns" value=$matches[2][0]|default:'4'}> <{assign var="max" value=$matches[3][0]|default:'4'}> <{assign var="products" value=$landing_page->getProducts( $max )}> <{/if}> <{/if}> <{/capture}> <{assign var="content" value=$content|replace:$match:$smarty.capture.product_grid}> <{/foreach}> <{/if}> <{* Replace shortcode with inline link. Ie: [link type="product" id="1234" text="Click here"] [link type="category" id="1234" text="Click here"] [link type="landingpage" id="1234" text="Click here"] [link type="page" id="1234" text="Click here"] [link type="blogpost" id="1234" text="Click here"] *}> <{if preg_match_all('/\[link type="([^"]+)" id="([^"]+)"(?: text="([^"]+)")?\]/', $content, $matches)}> <{foreach from=$matches[0] item=$match}> <{assign var="link_id" value=''}> <{assign var="link_text" value=''}> <{assign var="object" value=''}> <{$type=[]}> <{if preg_match('/type="([^"]+)"/', $match, $type)}> <{assign var="link_type" value=$type[1]}> <{/if}> <{$id=[]}> <{if preg_match('/id="([^"]+)"/', $match, $id)}> <{assign var="link_id" value=$id[1]}> <{/if}> <{$text=[]}> <{if preg_match('/text="([^"]+)"/', $match, $text)}> <{assign var="link_text" value=$text[1]}> <{/if}> <{if $link_type == "product"}> <{assign var="object" value=$webshop->getProductById($link_id)}> <{elseif $link_type == "category"}> <{assign var="object" value=$webshop->getCategory($link_id)}> <{elseif $link_type == "landingpage"}> <{assign var="object" value=$webshop->getLandingPage($link_id)}> <{elseif $link_type == "page"}> <{assign var="object" value=$webshop->getPage($link_id)}> <{elseif $link_type == "blogpost"}> <{assign var="object" value=$webshop->getBlogPost($link_id)}> <{/if}> <{if $object}> <{assign var="object_url" value=$object->getRemoteUrl()}> <{assign var="object_name" value=$object->getName()}> <{if !$link_text}> <{assign var="link_text" value=$object_name}> <{/if}> <{capture name="inline_link"}> <{$link_text}> <{/capture}> <{else}> <{capture name="inline_link"}> <{t}>Link not found<{/t}> <{/capture}> <{/if}> <{assign var="content" value=$content|replace:$match:$smarty.capture.inline_link}> <{/foreach}> <{/if}> <{* Output *}> <{$content}>