Skip to content

Commit

Permalink
[TASK] Remove canonical link if noindex
Browse files Browse the repository at this point in the history
Some frontend and backend optimizations for canonical links

- Change position of canonical link input field in backend
- Hide canonical link input if in backend "no_index" toggle is inactive
- Reload page by changing "no_index" toggle in backend

Resolves: #86515
Releases: master
Change-Id: I70dd8e36ada7c1a4c9b5aec7f69866eae0592945
Reviewed-on: https://review.typo3.org/58600
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Kummer <typo3@enobe.de>
Tested-by: Joerg Kummer <typo3@enobe.de>
Reviewed-by: Felix Althaus <felix.althaus@undkonsorten.com>
Tested-by: Felix Althaus <felix.althaus@undkonsorten.com>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
gmartino27 authored and bmack committed Oct 28, 2018
1 parent 936dd95 commit e92b161
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 38 deletions.
6 changes: 3 additions & 3 deletions typo3/sysext/seo/Classes/Canonical/CanonicalGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function generate(): string

if (!empty($href)) {
$canonical = '<link ' . GeneralUtility::implodeAttributes([
'rel' => 'canonical',
'href' => $href
], true) . '/>' . LF;
'rel' => 'canonical',
'href' => $href
], true) . '/>' . LF;
$this->typoScriptFrontendController->additionalHeaderData[] = $canonical;
return $canonical;
}
Expand Down
65 changes: 30 additions & 35 deletions typo3/sysext/seo/Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.palettes.robots',
'showitem' => 'no_index;LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.no_index_formlabel, no_follow;LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.no_follow_formlabel',
],
'canonical' => [
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.palettes.canonical',
'showitem' => 'canonical_link',
],
'opengraph' => [
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.palettes.opengraph',
'showitem' => 'og_title, --linebreak--, og_description, --linebreak--, og_image',
Expand All @@ -19,10 +23,6 @@
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.palettes.twittercards',
'showitem' => 'twitter_title, --linebreak--, twitter_description, --linebreak--, twitter_image',
],
'canonical' => [
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.palettes.canonical',
'showitem' => 'canonical_link',
],
],
'columns' => [
'seo_title' => [
Expand All @@ -39,6 +39,7 @@
'no_index' => [
'exclude' => true,
'l10n_mode' => 'exclude',
'onChange' => 'reload',
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.no_index',
'config' => [
'type' => 'check',
Expand Down Expand Up @@ -68,6 +69,28 @@
]
]
],
'canonical_link' => [
'exclude' => true,
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.canonical_link',
'displayCond' => 'FIELD:no_index:=:0',
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'size' => 50,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'options' => [
'title' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.canonical_link',
'blindLinkFields' => 'class,target,title',
'blindLinkOptions' => 'mail,folder,file'
],
],
],
'softref' => 'typolink'
]
],
'og_title' => [
'exclude' => true,
'l10n_mode' => 'prefixLangTitle',
Expand Down Expand Up @@ -166,27 +189,6 @@
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
)
],
'canonical_link' => [
'exclude' => true,
'label' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.canonical_link',
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'size' => 50,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'options' => [
'title' => 'LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.canonical_link',
'blindLinkFields' => 'class,target,title',
'blindLinkOptions' => 'mail,folder,file'
],
],
],
'softref' => 'typolink'
]
],
],
];

Expand All @@ -197,17 +199,10 @@
--div--;LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.tabs.seo,
--palette--;;seo,
--palette--;;robots,
--palette--;;canonical,',
(string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT,
'after:title'
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'pages',
'
--palette--;;canonical,
--div--;LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.tabs.socialmedia,
--palette--;;opengraph,
--palette--;;twittercards,',
--palette--;;twittercards',
(string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT,
'after:canonical_link'
'after:title'
);

0 comments on commit e92b161

Please sign in to comment.