diff --git a/classes/TemplateOperators/EzObjectRelationListContent.php b/classes/TemplateOperators/EzObjectRelationListContent.php new file mode 100644 index 0000000..b9dcca7 --- /dev/null +++ b/classes/TemplateOperators/EzObjectRelationListContent.php @@ -0,0 +1,32 @@ + array(Node) + * ``` + * + * Will return the node directly, if only one is related. + */ +class EzObjectRelationListContent extends \SwarkOperator +{ + function __construct() + { + parent::__construct('ezobjectrelationlist_content'); + } + + static function execute($ezSelectionField, $namedParameters) + { + $classContent = $ezSelectionField->attribute('content'); + $relationList = $classContent['relation_list']; + + $nodeIds = array_map(function($node) { + return $node['node_id']; + }, $relationList); + + return \eZContentObjectTreeNode::fetch($nodeIds); + } +} \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index b601bc1..fecee63 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -87,7 +87,7 @@ Operators .. raw:: html
- + .. include:: operators/is_post_request.rst .. raw:: html @@ -270,6 +270,12 @@ Operators .. include:: operators/ezselection_content.rst +.. raw:: html + +
+ +.. include:: operators/ezobjectrelationlist_content.rst + Workflow event types ==================== diff --git a/doc/operators/ezobjectrelationlist_content.rst b/doc/operators/ezobjectrelationlist_content.rst new file mode 100644 index 0000000..0f5a36b --- /dev/null +++ b/doc/operators/ezobjectrelationlist_content.rst @@ -0,0 +1,37 @@ +ezobjectrelationlist_content +------------------- + +Summary +~~~~~~~ +Alternative for getting ezobjectrelationlist content as a list of nodes, instead of an array which does not have the nodes. + +Will return the node directly, if only one is related. + +Usage +~~~~~ +:: + + field|ezobjectrelationlist_content + +Parameters +~~~~~~~~~~ +.. list-table:: + :header-rows: 1 + + * - Name + - Description + - Required + - Default + + * - `field` + - eZObjectRelationList field from data_map. Do note that we do not pass in the content, and instead the entire field. + - Yes + - + +Examples +~~~~~~~~ +:: + + {$data_map.my_ezobjectrelationlist_field|ezobjectrelationlist_content} + +Returns array of nodes, or the node directly: `array(eZContentObjectTreeNode)|eZContentObjectTreeNode`. diff --git a/settings/swark.ini b/settings/swark.ini index 33ed47b..a80d6d6 100644 --- a/settings/swark.ini +++ b/settings/swark.ini @@ -50,5 +50,6 @@ OperatorMap[variable_names]=SwarkVariableNamesOperator OperatorMap[get_scheme]=SwarkGetSchemeOperator OperatorMap[url_modify]=Swark\TemplateOperators\UrlModifier OperatorMap[ezselection_content]=Swark\TemplateOperators\EzSelectionContent +OperatorMap[ezobjectrelationlist_content]=Swark\TemplateOperators\EzObjectRelationListContent OperatorMap[embed_design_file]=Swark\TemplateOperators\EmbedDesignFile OperatorMap[dump]=Swark\TemplateOperators\DebugDump