diff --git a/Classes/ViewHelpers/Render/ParentViewHelper.php b/Classes/ViewHelpers/Render/ParentViewHelper.php
new file mode 100644
index 000000000..d6a03b7d0
--- /dev/null
+++ b/Classes/ViewHelpers/Render/ParentViewHelper.php
@@ -0,0 +1,76 @@
+registerArgument('partial', 'string', 'Partial to render');
+ }
+
+ /**
+ * @return string
+ */
+ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
+ {
+ $partial = $arguments['partial'] ?? null;
+ if ($partial === null) {
+ return '';
+ }
+
+ $format = 'html';
+ $variables = (array) $renderingContext->getVariableProvider()->getAll();
+ $partialRootPaths = $variables['__unprocessedPartialRootPaths'] ?? $renderingContext->getTemplatePaths()->getPartialRootPaths();
+ $partialRootPaths = array_filter($partialRootPaths, function ($path) use ($partial, $format) {
+ return file_exists($path . $partial . '.' . $format);
+ });
+ if (count($partialRootPaths) === 1) {
+ return '';
+ }
+ array_pop($partialRootPaths);
+ $currentTemplate = end($partialRootPaths) . $partial . '.' . $format;
+
+ if ((new Typo3Version())->getMajorVersion() < 12) {
+ $view = GeneralUtility::makeInstance(StandaloneView::class);
+ } else {
+ $context = GeneralUtility::makeInstance(RenderingContextFactory::class)->create();
+ $context->setRequest($renderingContext->getRequest());
+ $view = GeneralUtility::makeInstance(StandaloneView::class, $context);
+ }
+ $view->assignMultiple($variables);
+ $view->assign('__unprocessedPartialRootPaths', $partialRootPaths);
+ $view->setLayoutRootPaths($renderingContext->getTemplatePaths()->getLayoutRootPaths());
+ $view->setPartialRootPaths($renderingContext->getTemplatePaths()->getPartialRootPaths());
+ $view->setTemplateRootPaths($renderingContext->getTemplatePaths()->getTemplateRootPaths());
+ $view->setTemplatePathAndFilename($currentTemplate);
+
+ return $view->render();
+ }
+}
diff --git a/Tests/Functional/ViewHelpers/Render/ParentViewHelperTest.php b/Tests/Functional/ViewHelpers/Render/ParentViewHelperTest.php
new file mode 100644
index 000000000..cc038ea04
--- /dev/null
+++ b/Tests/Functional/ViewHelpers/Render/ParentViewHelperTest.php
@@ -0,0 +1,168 @@
+get(RenderingContextFactory::class)->create([
+ 'partialRootPaths' => [
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level1/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level2/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level3/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level4/',
+ ]
+ ]);
+
+ $context->getTemplatePaths()->setTemplateSource('');
+ $view = (new TemplateView($context));
+
+ self::assertSame(
+ implode(
+ PHP_EOL,
+ [
+ '',
+ 'BASIC - LEVEL1',
+ '',
+ 'BASIC - LEVEL2',
+ '',
+ 'BASIC - LEVEL3',
+ '',
+ 'BASIC - LEVEL4',
+ '',
+ ]
+ ),
+ $view->render()
+ );
+ }
+
+ /**
+ * @test
+ */
+ public function renderFirstAndLast(): void
+ {
+ $context = $this->get(RenderingContextFactory::class)->create([
+ 'partialRootPaths' => [
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level1/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level2/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level3/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level4/',
+ ]
+ ]);
+
+ $context->getTemplatePaths()->setTemplateSource('');
+ $view = (new TemplateView($context));
+
+ self::assertSame(
+ implode(
+ PHP_EOL,
+ [
+ '',
+ 'BASIC - LEVEL1',
+ '',
+ 'BASIC - LEVEL4',
+ '',
+ ]
+ ),
+ $view->render()
+ );
+ }
+
+ /**
+ * @test
+ */
+ public function renderNoParent(): void
+ {
+ $context = $this->get(RenderingContextFactory::class)->create([
+ 'partialRootPaths' => [
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoParent/Level1/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoParent/Level2/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoParent/Level3/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoParent/Level4/',
+ ]
+ ]);
+
+ $context->getTemplatePaths()->setTemplateSource('');
+ $view = (new TemplateView($context));
+
+ self::assertSame(
+ implode(
+ PHP_EOL,
+ [
+ '',
+ 'BASIC - LEVEL4',
+ '',
+ ]
+ ),
+ $view->render()
+ );
+ }
+
+ /**
+ * @test
+ */
+ public function renderOnlyOnePartialPath(): void
+ {
+ $context = $this->get(RenderingContextFactory::class)->create([
+ 'partialRootPaths' => [
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/OnlyOnePartialPath/Level1/',
+ ]
+ ]);
+ $context->getTemplatePaths()->setTemplateSource('');
+ $view = (new TemplateView($context));
+
+ self::assertSame(
+ implode(
+ PHP_EOL,
+ [
+ '',
+ 'BASIC - LEVEL1',
+ '',
+ ]
+ ),
+ $view->render()
+ );
+ }
+
+ /**
+ * @test
+ */
+ public function renderNoneExist(): void
+ {
+ $context = $this->get(RenderingContextFactory::class)->create([
+ 'partialRootPaths' => [
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoneExist/Level1/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoneExist/Level2/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoneExist/Level3/',
+ 'EXT:demo_package/Resources/Private/ParentViewHelperTest/Partials/NoneExist/Level4/',
+ ]
+ ]);
+
+ $context->getTemplatePaths()->setTemplateSource('');
+ $view = (new TemplateView($context));
+
+ $this->expectException(InvalidTemplateResourceException::class);
+ $view->render();
+ }
+}
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level1/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level1/Partial.html
new file mode 100644
index 000000000..7a2c27823
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level1/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL1
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level2/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level2/Partial.html
new file mode 100644
index 000000000..3a5baaf10
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level2/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL2
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level3/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level3/Partial.html
new file mode 100644
index 000000000..5bfc2e5d5
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level3/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL3
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level4/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level4/Partial.html
new file mode 100644
index 000000000..17dd9947a
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/ExistAll/Level4/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL4
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level1/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level1/Partial.html
new file mode 100644
index 000000000..7a2c27823
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level1/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL1
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level4/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level4/Partial.html
new file mode 100644
index 000000000..17dd9947a
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/FirstAndLast/Level4/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL4
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/NoParent/Level4/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/NoParent/Level4/Partial.html
new file mode 100644
index 000000000..17dd9947a
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/NoParent/Level4/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL4
diff --git a/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/OnlyOnePartialPath/Level1/Partial.html b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/OnlyOnePartialPath/Level1/Partial.html
new file mode 100644
index 000000000..7a2c27823
--- /dev/null
+++ b/Tests/Packages/demo_package/Resources/Private/ParentViewHelperTest/Partials/OnlyOnePartialPath/Level1/Partial.html
@@ -0,0 +1,2 @@
+
+BASIC - LEVEL1