< Back
Print

Placeholders in format plugins

Chaining format plugins already allows for pretty extensive transformations, but they’re limited to only one input value.

Example: Calculating Volume

Our first example will be calculating the volume in cubic centimeters from these values:

The formula we’ll use is “height * width * depth”.

Preparation

We’ll start by creating the datamap-row and loading the height (ID: 35).

After that we’ll prepare out first multiplication.

 

When trying to configure the multiplication, you might recognize the problem.
We don’t want to multiply with a fixed value, but rather with another attribute.

Assigning Placeholders

To get around this restriction, we can use placeholders.
Go ahead and open the corresponding spoiler.


The upper option allows you to select how placeholders should be handled if they have no value.

Below you can find a kind of mini-datamap which allows you to load and format values which are then useable throughout this plugin.
Use this assignment to load the width into a placeholder.

Because we need the width in centimeters, we need to divide it by 10 first.
Chain another plugin, after the unformatted value of the width and configure it.

Using Placeholders

After having configured the width, return to the plugin, where you assigned the placeholder.

It’s time to put our placeholder to use.
The syntax to use a placeholder is:

{placeholder-name}

Our current calculation would be: height * (width / 10)
The correct value for that calculation is 24,848.49
Let’s take a look at our export.

So far, so good. We’re still missing the depth however.
Adding the depth is as simple as chaining another multiplication and using the depth as a placeholder.
In this case, the depth is also given as mm, so we need to divide by 10 first.

Now our calculation is: (height * (width / 10) ) * (depth / 10)
And sure enough, when looking at our export, we can see our volume.

 

List of predefined placeholders

With the connector version 1.14.0, a list of predefined placeholders was added. These are very convenient when it comes to classic values that are often used in the connector configuration. They must still be enclosed with brackets {pos}.

  • count or pos – Returns the current count of how often the placeholder was reached. It is useful in many connectors to have a unique identifier.
  • StoreView – Returns the language key that was set in the language mapping of the datamap (e.g. default, en-US).
  • LanguageId – Returns the Contentserv ID of the current language.
  • LanguageShortName – Returns the short name / key of the current language.
  • csid – Returns the Contentserv ID of the current product / object.
  • csclass – Returns the object type of the current product / object (e.g. Pdmarticle, Mamfile)
  • fieldid – Returns the Contentserv ID of the attribute that was passed to the format plugin.
  • fieldname – Returns the label of the attribute that was passed to the format plugin.
  • fieldexternalkey – Returns the external key of the attribute that was passed to the format plugin.
  • ResultValue – Returns the result value of the format plugin. Only works in specific configurations.

Teaser with Fallback

Another use for placeholders is assigning an alternative value, if the intended output is not available.
For this example, we’re going to export a teaser text.


But not all our products have a teaser configured.

Preparation

This time we’re going to export only using placeholders.
To start off, we’ll create a new datamap-row.
The plugin “send configured parameter value” is a good fit for working with placeholders.
It doesn’t require any input, so we’ll just use the PdmarticleID as a dummy value.

Alternative / Fallback Placeholders

We’ll configure the label and teaser as placeholders.
Both are language dependent, but our dummy value (PdmarticleID) is not, so we’ll override the language dependency at the bottom.
Lastly we’ll use the syntax for alternative placeholders.
{placeholder1|placeholder2}
Simply write the placeholder names inside the brackets seperated by pipes (|) in the order you want to use them.
The connector will check them one after another and use the first one that’s not empty.
You can add as many fallback placeholders as you want.
{placeholder1|placeholder2|placeholder3|…}

After configuring, we can test our configuration:

As you can see, instead of an empty value, the connector inserted the label as a fallback.

Summary

Placeholders allow you to set plugin options using values from your export (e.g.: a product).
They shall be useable in most configurations. If you notice they’re not supported in one of our format plugins, feel free to contact us.
Placeholders also allow you to quickly set fallback values, even inside configurations.

Was this article helpful?
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Table of Contents