With templates you can display products in any way you want on your website. They offer you absolute flexibility. You can easily edit the templates in the backend of WordPress.
The structure of a template is simply designed, think of it like Word's mail merge function. You define a template and insert placeholders. When outputting your WordPress page, this placeholder will be replaced with the actual value.
Templates can be managed via "affiliate-toolkit" -> "Templates". Here you can create and edit any templates.
System templates are all templates that are supplied by the plugin. These templates cannot be edited but you will find a duplicate function.
After you duplicate the template, you can edit and use it as a custom template.
You will also always find a preview image for all system templates on the right side of the overview.
Easily duplicate the templates from within the system templates.
If you want to create a template from nothing, just create a new template and use the toolbar above the editor. Note that the template must contain a loop.
The best way to do this is to use a system template.
For example, this template outputs the product title.
Any template placeholder can be inserted via the toolbar. Even user-defined fields can be conveniently inserted.
We have been using the BladeOne template engine for some time now. It is a library which is attached to Laravel. You can basically just run PHP code with it but with Blade you have some simple functions especially for templates.
Here you can find more information:
https://github.com/EFTEC/BladeOne#bladeone-blade-template-engine
By default we always pass some PHP classes which can be used for template rendering.
$products | If products have been passed, they are kept as an array in this variable. |
$shops | If stores are passed, they are kept as an array in the Veriable. |
$formatter | This is a formatter class with various functions for formatting. |
$shop | Here from the first product always the first store is inserted. |
$parameters | This class contains all parameters from the shortcode and the page. |
$translator | This class contains functions for translating products. |
With this code snippet you can pass your own objects to the template engine.
/**
* Fügt eigene Objekte für Bladeabfrage an
*
* @param array $bladedata Das Array welches alle Klassen für die Engine bereit hält.
* @return array Rückgabe des geänderten Arrays
*/
function atkp_modify_bladedata_callback($bladedata) {
$bladedata['eigenes'] = 'hallo';
//Die Variable "$eigenes" ist nun in der BladeEngine verfügbar.
return $bladedata;
}
add_action('atkp_modify_bladedata', 'atkp_modify_bladedata_callback');
To facilitate the work with the templates, we have implemented an import and an export function. This way you can easily copy already created templates from installation to installation.
You can find the function in affiliate-toolkit, templates and "Import template":
After that you can upload the file and import the template.
Note that you can only upload ".txt" files. ZIP files must be unzipped first.
Templates can be easily exported in the overview.
After that, the download of a .txt file will begin.
Once you understand the templates, you can create your own template relatively quickly. Until then, you need to spend a little time with the tool.
First of all, you should activate the error display under affiliate-toolkit -> Display settings.
Mostly variables are used which are not (yet) available.
Here is an example:
In this example $product is used before $product is used in the "@foreach". An error would be generated here. If you move the line up with "@foreach", the error would be fixed.