The object relations datatype is one of the most powerful datatypes in eZ Publish. In some cases, it is useful to associate data not to either of the objects involved in the relation, but to the relation itself. For example, you might want to mark a person as an author on one book, a contributor on another book, and an editor on another book, all while maintaining only one record for that author. Mugo has created an extension to add cross-reference data to object relations.
The extension Mugo Object Relations provides a new datatype:
Once an attribute of the new datatype is added, it will show the familiar options as for a standard "Object relations" attribute but with an area to configure the cross-reference information:
As shown in the screenshot above, you can allow the cross-reference data to be entered via a text field or you can define a set of options for a dropdown list.
When you create a new object that has a "Mugo object relations" attribute, you can select the cross reference information...
... or if it was configured as such, you can type it in:
The data associated with the relation can be accessed in your templates via the "xrefoptionaldata" key within the "relation_list" attribute. Here is a simple code sample that fetches an object with a "Mugo object relations" attribute and lists the related object names along with the data associated with each relation:
{set $node = fetch( 'content', 'node', hash( 'node_id', 75 ))} relations for {$node.name} object:<br/><br/> {def $relation_node = null} {foreach $node.data_map.relations.content.relation_list as $relation} {set $relation_node = fetch( 'content', 'node', hash( 'node_id', $relation.node_id ))} {$relation_node.name}: "{$relation.xrefoptionaldata}"<br/> {/foreach}
The extension comes with a simple eZ Find PHP class for storing the datatype's data in a Solr search index.
Download and contribute to Mugo Object Relations on GitHub: https://github.com/mugoweb/mugoobjectrelations
We're a group of web experts who solve complex web problems.
Learn more about us »Many years of experience with complex websites allows us to offer total solutions.
Learn more about what we can do »We've solved problems across North America and around the world.
Learn more about what we've done »
Comments
blog comments powered by Disqus