Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Show Table of Contents

What are templates and how do I create them?

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

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.

Create your own 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.

Template Template Example

For example, this template outputs the product title.

Template placeholder

Any template placeholder can be inserted via the toolbar. Even user-defined fields can be conveniently inserted.

Technical background

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.

$productsIf products have been passed, they are kept as an array in this variable.
$shopsIf stores are passed, they are kept as an array in the Veriable.
$formatterThis is a formatter class with various functions for formatting.
$shopHere from the first product always the first store is inserted.
$parametersThis class contains all parameters from the shortcode and the page.
$translatorThis class contains functions for translating products.

Provide your own PHP objects

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');

Import and export templates

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.

Import templates

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.

Export templates

Templates can be easily exported in the overview.

After that, the download of a .txt file will begin.

Problem handling in template design

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.

Show error

First of all, you should activate the error display under affiliate-toolkit -> Display settings.

Access to variables

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.

Updated: 6. February 2023
Still not using affiliate-toolkit?
Setup takes less than 5 minutes and you can start to import first products!
Learn more about the packagesDownload FREE Version
Still need help?
Submit Your Question
Please give us the details, our support team will get back to you.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram