Feed Import is a module that allows you to import content into entities from various file types (like XML, HTML, CSV).
In this page I will show available filters from FeedImportFilter class (in file feed_import_filter.inc.php).
Quick note: when using Feed Import UI don't forget that params are inserted one per line. Also you can use for filter any defined function. Take a look at this image to see how filters are in UI
From version 2.2 is no longer required to write FeedImportFilter for functions contained by this class, you can use just ::func.
Instead of writing FeedImportFilter::removeDoubleSpaces write just ::removeDoubleSpaces.
Filters for cleaning data
FeedImportFilter::removeCDATA
Extracts content of CDATA.
Receives one param: the string (or array of strings) to be processed.
FeedImportFilter::trim
Trims a text.
Receives two params:
the string (or array of strings) to be processed
(optional, default is whitespace chars) chars to be trimmed.
For more info take a look at trim function.
FeedImportFilter::removeDoubleSpaces
Removes all double spaces from a text and trims the text.
Receives one param: the string (or array of strings) to be processed.
FeedImportFilter::stripTags
Strips html tags from a text.
Receives two params:
the string (or array of strings) to be processed
(optional, default is empty) allowable tags.
For more info take a look at strip_tags function.
FeedImportFilter::removeTags
Remove undesired tags with their content from text.
Receives two params:
the string (or array of strings) to be processed
string containing undesired tags separated by a space.
This is very useful for removing dangerous script tags.
Filters for altering data
FeedImportFilter::replace
Performs a replace on a text.
Receives four params:
the string (or array of strings) to be processed
string containing value to be replaced
(optional, default is empty string) string containing new value
(optional, default is 0) integer 1 for performing an insensitive replace
FeedImportFilter::append
Appends a text.
Receives two params:
the string (or array of strings) where to append
the append value.
FeedImportFilter::prepend
Prepends a text.
Receives two params:
the string (or array of strings) where to prepend
the prepend value.
FeedImportFilter::convertEncoding
Convert text to requested character encoding.
Receives three params:
the string (or array of strings) to be converted
(optional, default is "utf-8") output charset
(optional, default is "ISO-8859-1// TRANSLIT") input charset
For more info take a look at iconv function.
FeedImportFilter::userHashPassword
Returns hashed string of a password. Used to save user password in database.
Receives one param: the string (or array of strings) to be hashed.
Filters for arrays or objects
FeedImportFilter::json
Decode a json string. Field token is replaced with field value.
Receives 2 params:
field value
json to decode
FeedImportFilter::callMethod
Call a specified method from an object.
Receives n params:
the object which contains method
the method name
arguments to pass to method name
FeedImportFilter::split
Splits a string by a delimiter.
Receives two params:
the string (or array of strings) to be splitted
(optional, default to PHP_EOL constant value (end of line)) delimiter string
This function returns an array.
FeedImportFilter::join
This is the opposite of FeedImportFilter::split filter, joins array elements with a glue string.
Receives two params:
the array of strings to be joined
(optional, default to PHP_EOL constant value (end of line)) glue string
FeedImportFilter::merge
Merge all array levels into one array.
Receives one param: the nested array to be merged.
FeedImportFilter::getProperty
Extract property values from an array or object.
Receives n params:
first is the array/object from where to get properties
other params, each represents property name
This is usefull when extracting attributes with xpath, take a look at Feed Import HTML example to see the context where is used.
FeedImportFilter::setProperty
Set property for an array or object.
Receives 3 params:
first is the array/object where to set properties
property name to set
value for property
FeedImportFilter::removeProperty
Remove property for an array or object.
Receives 2 params:
first is the array/object from where to remove properties
property name to be removed
FeedImportFilter::toArray
Converts to array.
Receives 1 param:
the object to convert to array
FeedImportFilter::toObject
Converts to object.
Receives 1 param:
the array to convert to object
Filters for taxonomy
FeedImportFilter::getVidFromName
Gets vocabulary vid using vocabulary name.
Receives one param: vocabulary name.
FeedImportFilter::getTaxonomyIdByName
Returns terms ids from a vocabulary using term names.
Receives two params:
the string (or array of strings) containing terms name
vocabulary id or vocabulary name
FeedImportFilter::setTaxonomyTerms
Returns terms ids from a vocabulary using term names but also inserts new terms.
Receives two params:
the string (or array of strings) containing terms name
vocabulary id or vocabulary name
This is useful for tagging content, see Feed Import XML example for how to use it.
Filters for external data
FeedImportFilter::saveFile
Saves external content to a specified path.
Receives three params:
the string (or array of strings) containing url to data
(optional, default is public://) path where to save file
(optional, default is 0) 0 to rename or 1 to replace the file (since v2.6)
FeedImportFilter::saveImage
This is an alias for FeedImportFilter::saveFile.
Attachment | Size |
---|---|
feed-import-filters.png | 23.98 KB |
Comments
Space
How can I append space (e.g space pipe space ' | ')? When I use FeedImportFilter::append, space was remove from filter :(
did not help :(Concat
How can I use concat function? E.g.
concat(language/@title, " | ", language/@level)
?