Admin
Purple Wires

Purple Wires: Conditional imports

8min

Purple Hub



Summary

Purple Wires allows conditional imports, learn how to import data based on conditions with this article. From taxonomy import and conversion to fetching generic meta data, learn how to define allocations and conditions for meta fields.



Preconditions



Description

Import based on conditions

If not using the 'Mapping configurator' you can define your own configuration by the following rules.

Taxonomy import

Taxonomy split up

taxonomyItem:convert[:split] where taxonomy can be 'category', 'tag' or any qualified own taxonomy slug.

Split Example

categoryItem:convert:/ on fetched data "germany/news/economy" will return the three categories 'germany', 'news' and 'economy'.

mytaxItem:convert on fetched data "germany news economy" will return the three elements 'germany', 'news' and 'economy' for own taxonomy 'My Tax' (with the slug 'mytax')

Taxonomy conversion

taxonomyItem:match:allocation:condition where taxonomy can be 'category', 'tag' or any qualified own taxonomy slug.

Argument match defines that the allocation string will be set by defined condition rule. This will happen after an optional conversion (as described before)

Example

categoryItem:match:germany:deutschland on fetched data "germany" will return the category 'deutschland'.

categoryItem:convert:/ and categoryItem:match:germany:deutschland on fetched data "germany/news/economy" will result in return of the three categories 'deutschland', 'news' and 'economy'

Meta import

Generic meta fetching

metaItem:fieldname[:format[:split]]

  • Argument fieldname is the name of the meta-field
  • Argument format (optional) can be r (repeater)
  • If 'repeater' is choosen as format, the first param needs to be defined in ACF fieldname syntax, e.g. repeater%item, where first value (repeater) describes the repeaters name and second value (item) describes the repeaters subfield. The third parameter split will be the char to split up the given string. If param is empty, data will be split by blank spaces.

Allocations & conditions

metaItem:fieldname:allocation

Within meta-storage you can define allocations where allocation will be set, if XML element value is not empty. Reserved single chars are 's', 'a' and 't'.

metaItem:fieldname:allocation:==string

If the XML element value is equal to string, the allocation will be done.

metaItem:fieldname:allocation:!=string

If the XML element value isn't equal to string, the allocation will be done.

metaItem:fieldname:allocation:%=string

If the XML element value contains string, the allocation will be done.

metaItem:fieldname:allocation:%!string

If the XML element value doesn't contain string, the allocation will be done.

'Equality Conditions' are case-sensitive, 'containing conditions' are not case-sensitive