shel/neos-cross-contentrepository-references
Composer 安装命令:
composer require shel/neos-cross-contentrepository-references
包简介
Allows referencing content from other content repositories in the Neos CMS backend
README 文档
README
This package for NeosCMS makes it possible to reference nodes from any content repository via the inspector - not only from the content repository the currently edited node belongs to.
Neos' built-in reference and references property types are confined to the
content repository of the edited node. When a project uses multiple content
repositories (e.g. a central "content hub" plus per-site repositories), this
package fills the gap by providing a datasource-driven editor and a Fusion
helper to resolve the selected nodes again in the frontend.
Features
ReferencesDataSource(cross-content-repository-references) — a Neos datasource that lists nodes from an arbitrary content repository for use in the inspectorSelectBoxEditor.- The
startingPointargument includes the content repository id using the pattern/<contentRepositoryId>/<RootNodeType>/<siteName>, e.g./hub/<Neos.Neos:Sites>/example-site. - Selected nodes are stored as serialized
CrossContentRepositoryReferenceJSON strings — one string for a single reference, an array of strings for multiple references. The serialized form contains only the content repository id and node aggregate id; the workspace and dimension space point are resolved from the rendering context (the context node) when the reference is loaded in Fusion. NodeHelperEel helper (Shel.Neos.CrossContentRepositoryReferences.Node) to resolve a node (or a list of nodes) from a serializedCrossContentRepositoryReferencein Fusion, using a context node for the workspace and dimension.
Installation
Run this in your site package:
composer require --no-update shel/neos-cross-contentrepository-references
Then run composer update in your project root.
Usage
Configure a property
The package ships 2 node type presets crossContentRepositoryReference and crossContentRepositoryReferences. You can use them to configure a property
of any node type:
'Your.Package:NodeType': properties: myCrossReference: options: preset: 'crossContentRepositoryReference' ui: label: 'My reference' inspector: editorOptions: placeholder: 'Select a node' dataSourceAdditionalData: startingPoint: '/default/<Neos.Neos:Sites>/neos-demo' nodeTypes: ['Neos.Neos:Document']
startingPoint format
The startingPoint is not relative to the currently edited content
repository as in Neos' default behaviour. Instead it contains the content
repository id as its first segment:
/<contentRepositoryId>/<RootNodeType>/<siteName>
Examples:
/default/<Neos.Neos:Sites>/my-site— themy-sitesite in thedefaultCR/hub/<Neos.Neos:Sites>/content-hub— thecontent-hubsite in thehubCR
Available dataSourceAdditionalData options
| Option | Required | Default | Description |
|---|---|---|---|
startingPoint |
yes | - | /<crId>/<RootNodeType>/<siteName> |
nodeTypes |
no | Neos.Neos:Document |
Node type names, e.g. [Neos.Neos:Document, Foo.Bar:Baz] |
dimensionValues |
no | edited node's dimension space point | JSON object, e.g. {"language":"de"} |
searchTerm |
no | - | Fulltext search term to pre-filter results |
Resolving selected nodes in Fusion
Selected values are stored as serialized CrossContentRepositoryReference
JSON strings (containing only contentRepositoryId and nodeAggregateId).
Resolve them in Fusion via the registered Eel helper
Shel.Neos.CrossContentRepositoryReferences.Node, passing the context node
(whose workspace and dimension space point are used to load the referenced
node) and the serialized reference:
prototype(Your.Package:NodeType) {
# Single reference (property "crossReference" holds a JSON string)
referenceNode = ${Shel.Neos.CrossContentRepositoryReferences.Node.node(node, node.properties.crossReference)}
# Multiple references (property "crossReferences" holds an array of JSON strings)
referenceNodes = ${Shel.Neos.CrossContentRepositoryReferences.Node.nodes(node, node.properties.crossReferences)}
# Render the referenced nodes
renderedReferences = Neos.Fusion:Loop {
items = ${this.referenceNodes}
itemName = 'referencedNode'
itemRenderer = Neos.Neos:ContentCase {
nodePath = '/referencedNode'
}
}
}
The helper returns Neos\ContentRepository\Core\Projection\ContentGraph\Node
instances (or null / a filtered array if a node could not be resolved), so
you can use them like any other node - including q(node) FlowQuery
operations (note: FlowQuery operates within the referenced node's content
repository).
How it works
ReferencesDataSource::getData()parsesstartingPointinto aContentRepositoryIdand anAbsoluteNodePath, fetches a subgraph for the resolved content repository, workspace and dimension space point, and finds the start node viafindNodeByAbsolutePath().- It lists descendants using
ContentSubgraphInterface::findDescendantNodes()with aNodeTypeCriteriafilter and an optionalSearchTerm. - Each result is mapped to
{label, value, nodeType}wherevalueisCrossContentRepositoryReference::fromNode($node)->toJson()— containing only the content repository id and node aggregate id. This is what gets stored on the property. - In Fusion,
NodeHelper::node()deserializes theCrossContentRepositoryReference, fetches the matching content repository and a subgraph using the context node's workspace and dimension space point, and resolves the node viafindNodeById().
Contributions
Contributions are very welcome! Please create detailed issues and PRs.
If you use this package and want to support or speed up its development, get in touch with me.
License
See License
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2026-06-22