Fix: Make metadata values available in metadata wrap
This commit is contained in:
parent
744aa101d6
commit
1e43719538
|
@ -194,12 +194,22 @@ class MetadataController extends AbstractController
|
|||
'is_listed' => !$this->settings['showFull'],
|
||||
]);
|
||||
|
||||
// Collect raw metadata into an array that will be passed as data to cObj.
|
||||
// This lets metadata wraps reference (own or foreign) values via TypoScript "field".
|
||||
$metaCObjData = [];
|
||||
|
||||
$buildUrl = [];
|
||||
$i = 0;
|
||||
foreach ($metadataArray as $metadataSection) {
|
||||
$metaCObjData[$i] = [];
|
||||
|
||||
foreach ($metadataSection as $metadataName => $metadataValue) {
|
||||
// NOTE: Labels are to be escaped in Fluid template
|
||||
|
||||
$metaCObjData[$i][$metadataName] = is_array($metadataValue)
|
||||
? implode($this->settings['separator'], $metadataValue)
|
||||
: $metadataValue;
|
||||
|
||||
if ($metadataName == 'title') {
|
||||
// Get title of parent document if needed.
|
||||
if (empty($metadataValue) && $this->settings['getTitle'] && $this->document->getDoc()->parentId) {
|
||||
|
@ -263,6 +273,7 @@ class MetadataController extends AbstractController
|
|||
$this->view->assign('documentMetadataSections', $metadataArray);
|
||||
$this->view->assign('configMetadata', $metadataResult);
|
||||
$this->view->assign('separator', $this->settings['separator']);
|
||||
$this->view->assign('metaCObjData', $metaCObjData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class StdWrapViewHelper extends AbstractViewHelper
|
|||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('wrap', 'string', 'The wrap information', true);
|
||||
$this->registerArgument('data', 'array', 'Data for the content object', false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,11 +34,21 @@ class StdWrapViewHelper extends AbstractViewHelper
|
|||
public function render()
|
||||
{
|
||||
$wrap = $this->arguments['wrap'];
|
||||
$data = $this->arguments['data'] ?? [];
|
||||
|
||||
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
|
||||
$cObj = $configurationManager->getContentObject();
|
||||
|
||||
$insideContent = $this->renderChildren();
|
||||
|
||||
return $configurationManager->getContentObject()->stdWrap($insideContent, $wrap);
|
||||
$prevData = $cObj->data;
|
||||
$cObj->data = $data;
|
||||
try {
|
||||
$result = $cObj->stdWrap($insideContent, $wrap);
|
||||
} finally {
|
||||
$cObj->data = $prevData;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
data-namespace-typo3-fluid="true">
|
||||
|
||||
{configObject.wrap -> kitodo:metadataWrapVariable(name: 'metadataWrap')}
|
||||
<kitodo:stdWrap wrap="{metadataWrap.all}">
|
||||
<kitodo:stdWrap wrap="{metadataWrap.key}">{configObject.label}</kitodo:stdWrap>
|
||||
<f:variable name="metaSectionCObj" value="{metaCObjData.{sectionIterator.index}}" />
|
||||
<kitodo:stdWrap wrap="{metadataWrap.all}" data="{metaSectionCObj}">
|
||||
<kitodo:stdWrap wrap="{metadataWrap.key}" data="{metaSectionCObj}">{configObject.label}</kitodo:stdWrap>
|
||||
<f:for each="{documentMetadataSection.{configObject.indexName}}" as="value" iteration="iterator">
|
||||
<f:variable name="buildUrlVariable" value="{buildUrl.{sectionIterator.index}}" />
|
||||
<f:if condition="{buildUrlVariable.{configObject.indexName}}">
|
||||
|
@ -23,8 +24,8 @@
|
|||
<f:render partial="Metadata/LinkEntry" arguments="{_all}"/>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<kitodo:stdWrap wrap="{metadataWrap.value}">{value}</kitodo:stdWrap>
|
||||
<kitodo:stdWrap wrap="{metadataWrap.value}" data="{metaSectionCObj}">{value}</kitodo:stdWrap>
|
||||
</f:else>
|
||||
</f:if>
|
||||
</f:for>
|
||||
</kitodo:stdWrap>
|
||||
</kitodo:stdWrap>
|
||||
|
|
Loading…
Reference in New Issue