How to migrate a classic template to a blade template
We received a lot of queries how they can migrate the existing classic template to the new blade template engine. In this article we will try to clearify the situation.
Why did we removed the classic template?
The old classic template (placeholders %title%) was really nice for the beginning but with time we had a performance problem. The old engine was generating all placeholders and replaced the values after generation. This was inefficent and the engine was very unflexible. You had many limitation because you had a header, detail and body.
Compare a classic template to a blade template
We created a image to compare the classic templates to blade templates.
You can see the templates are now litte bit different and longer but it's still very simple.
Part 1 and 2 are header and footer. If you don't need it, you can just copy and paste the data. Between @foreach and @endforeach is the "detail" part of the template (green rectangle).
The templates are now little bit longer because we can use "@if" queries to hide the html elements. If you don't want to use it, you can ignore them.
We selected a few placeholders to show you some example for the new placeholders.
Classic placeholder | Blade placeholder
|
|
%bestseller_number% | {{$formatter->get_bestseller_number($product->item_idx)}} |
%titlelink% | {!! $formatter->get_title_link($product) !!} |
%shoplogo% | {!! $formatter->get_shop_logo($formatter->get_shop_value($product)) !!} |
%titlelink%>%short_title%%titlelinkmark% | {!! $formatter->get_title_link($product) !!}>{{$formatter->get_shorttitle($product)}}{!! $formatter->get_title_mark($product) !!} |
%info_text% | {!! $formatter->get_infotext($product) !!} |
%listprice_text% | {{$formatter->get_listpricetext($product, $translator->get_listprice() )}} |
%linktext%%linkmark% | {!! $formatter->get_button_text($product)!!}{!! $formatter->get_button_mark($product) !!} |
Looks simple but how can I start?
Your template need the header and footer section. If you insert this parts, you just need to insert your placeholder and your html code.
Code before your template
- <div class="atkp-container {{$parameters->cssContainerClass}}">
- @foreach ($products as $product)
Your template code
Now you can add your own placeholders. As example we will insert the title placeholder.
- {{$formatter->get_shorttitle($product)}}
Code after your template
- @endforeach
- @if(count($products) > 0 && atkp_options::$loader->get_show_disclaimer() && !$parameters->hidedisclaimer)
- <span class="atkp-disclaimer">{!! $formatter->get_disclaimer($products[0]) !!}</span>
- @endif
- </div>
The complete template
- <div class="atkp-container {{$parameters->cssContainerClass}}">
- @foreach ($products as $product)
- {{$formatter->get_shorttitle($product)}}
- @endforeach
- @if(count($products) > 0 && atkp_options::$loader->get_show_disclaimer() && !$parameters->hidedisclaimer)
- <span class="atkp-disclaimer">{!! $formatter->get_disclaimer($products[0]) !!}</span>
- @endif
- </div>
Placeholders for blade template
We will provide a full list of placeholders for your template.