Content Transforms

Content Transform plugins can be used to modify the format and extract data from content pulled by a content source. Internally they then accept content as a text string or as an array and must follow a Content Source plugin that is compatible with the data the transform accepts.

Content Transform plugins then provide content as a text string or as an array and must be followed by a Content Display plugin that is compatible with the data the transform provides.

UCP will warn in the edit dialog and provide error information if a transform is incompatible with the source or display.

Current content sources fall broadly into categories:

  1. Tranlating or modifying a text string.
  2. Extracting an array of data from a text string.
  3. Null transform, pass on whatever is provided.
[ Universal Content Puller ]

Content Transform Plugins

Content Transform Plugins are used to modify or transform content between source and display.

Functionality can be extended by adding plugin classes for additional Content Transform Plugins. Content Transform Plugins are simple classes that provide the functionality to output content in different ways. They should inherit from ContentTransformPluginBase. Details are provided by comments in the code.

Plugins can be added by placing the plugin classes at packages/anyPackageName/src/UCP/ContentTransforms/Plugins/PluginName or application/src/UCP/ContentTransforms/Plugins/PluginName. Plugins can also be similarly placed beneath any namespace declared in a package controller's AutoloaderRegistries.

[ Universal Content Puller ]

Markdown

Format Markdown into html.

Markdown is a plain text markup syntax that can be converted into HTML. Markdown Extra provides an extended syntax.
Accepts content as a string. Provides content as a string.

[ Universal Content Puller ]

Multi Selector

Advanced Extract from HTML or XML using multiple css selectors.

Extracts from HTML or XML using layers of css selectors to provide an array (multi level list) of the selected items.
Accepts content as a string. Provides content as an array.

Use this transform to extract tables or more deeply nested data from HTML or XML, RSS feeds. Also handles JSON sources by internally translating via XML.

[ Universal Content Puller ]

NL2BR

Format by converting new lines in the text to HTML line breaks.

Applies the php nl2br() function.
Accepts content as a string. Provides content as a string.

[ Universal Content Puller ]

Pass Through

Null transform.

No Transform. The content provided by the source is passed through without any modification or transformation.
Accepts content as any of string or array. Provides content as accepted.

[ Universal Content Puller ]

Selector

Extract from HTML using css selector.

Extracts from HTML or XML using a css selector to provide just the selected part of the source content.
Accepts content as a string. Provides content as a string.

Sometimes pulled content has unwanted classes that interfere with ideal rendering, for example, the classes 'container' and/or 'row' from a theme grid may be unwanted when pulled into an area that already has these classes. To fix such glitches you can list classes to remove. The html elements will remain, just the classes removed from class attributes.

[ Universal Content Puller ]

Table From CSV

Parse CSV into a table.

Parse text on the premise that it is CSV data for a table.
Accepts content as a string. Provides content as an array.

[ Universal Content Puller ]

Table From HTML

Parse HTML into a table.

Parse text on the premise that it is HTML and contains one or more tables. When there is more than one table, the required table can be selected by index starting at 1.
Accepts content as a string. Provides content as an array.

[ Universal Content Puller ]

Table From JSON

Parse JSON into a table.

Decode JSON text on the premise that it provides a table.
Accepts content as a string. Provides content as an array.

[ Universal Content Puller ]

Table From Text Lines

Parse lines of text into a table.

Split text into a table based solely on line breaks. A multiple new line starts a new row. A single new line starts a new column.
Accepts content as a string. Provides content as an array.

Additional Pages

About this Sidebar

Creating a sidebar for a group of pages without messing about with stacks is an easy use-case for Universal Content Puller.

This sidebar is edited once, within the main addon page for Universal Content Puller.

It is then pulled into all UCP sub-pages using a UCP block.

The Content Source is Parent Page, set to pull the Sidebar area from 2 pages from the top. The Content Transform is Selector, set to remove container and row classes that, when unnecessarily nested, could mess up the Bootstrap grid. The Content Display is Plain, which just outputs the transformed text.

In the advanced settings, sanitization is disabled as we trust the source page and don't want to strip out any formatting or functionality from the pulled sidebar.