Commit 2cb41db2 authored by Michael Oehlhof's avatar Michael Oehlhof Committed by Frans Saris
Browse files

[FEATURE] Page module: Show notice "Content is also shown on:"

If a page is selected in page module which content is also shown on
other pages, now a notice is shown with the titles and pid of these pages.

Resolves: #69572
Releases: master
Change-Id: Ie66564da98160825f5759c6ac4937fbbeaafdce0
Reviewed-on: https://review.typo3.org/51049

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Tested-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Frans Saris's avatarFrans Saris <franssaris@gmail.com>
Tested-by: Frans Saris's avatarFrans Saris <franssaris@gmail.com>
parent f9d17958
......@@ -644,10 +644,50 @@ class PageLayoutController
'state' => InfoboxViewHelper::STATE_INFO
]);
$content .= $view->render();
} else {
$links = $this->getPageLinksWhereContentIsAlsoShownOn($this->pageinfo['uid']);
if (!empty($links)) {
$message = sprintf($lang->getLL('content_on_pid_title'), $links);
$view->assignMultiple([
'title' => '',
'message' => $message,
'state' => InfoboxViewHelper::STATE_INFO
]);
$content .= $view->render();
}
}
return $content;
}
/**
* Get all pages with links where the content of a page $pageId is also shown on
*
* @param int $pageId
* @return string
*/
protected function getPageLinksWhereContentIsAlsoShownOn($pageId)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$queryBuilder
->select('*')
->from('pages')
->where($queryBuilder->expr()->eq('content_from_pid', $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)));
$links = [];
$rows = $queryBuilder->execute()->fetchAll();
if (!empty($rows)) {
foreach ($rows as $row) {
$linkToPid = $this->local_linkThisScript(['id' => $row['uid']]);
$title = BackendUtility::getRecordTitle('pages', $row);
$link = '<a href="' . htmlspecialchars($linkToPid) . '">' . htmlspecialchars($title) . ' (PID ' . (int)$row['uid'] . ')</a>';
$links[] = $link;
}
}
return implode(', ', $links);
}
/**
*
* @return string $title
......
......@@ -282,6 +282,9 @@
<trans-unit id="content_from_pid_title">
<source>Page uses content from this page: %s</source>
</trans-unit>
<trans-unit id="content_on_pid_title">
<source>This content is also shown on: %s</source>
</trans-unit>
<trans-unit id="pageIsExternalLinkMessage">
<source>Page is a link to the following external URL: %s</source>
</trans-unit>
......
.. include:: ../../Includes.txt
================================================================
Feature: #69572 - Page module Notice "Content is also shown on:"
================================================================
See :issue:`69572`
Description
===========
When page content is inherited from different page via "Show content from page" there is a notice displayed on the page.
This feature does the opposite and displays a notice on pages that are inherited elsewhere:
"This content is also shown on:"
Impact
======
On pages that are inherited elsewhere you see a notice with links to the pages where the content is inherited.
.. index:: Backend
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment