Open sorenmalling opened 5 months ago
To solve it, we implemented this with usage of the AfterUserLoggedInEvent
:
<?php
namespace OwnVendorName\YoastSeo\EventListener;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Authentication\Event\AfterUserLoggedInEvent;
final class HideYoastPreviewByDefault
{
public function __invoke(AfterUserLoggedInEvent $event): void
{
if (
$event->getUser() instanceof BackendUserAuthentication
) {
$settingSet = $event->getUser()->uc['hideYoastInPageModule'] ?? false;
if ($settingSet === false) {
$event->getUser()->uc['hideYoastInPageModule'] = true;
$event->getUser()->writeUC();
}
}
}
}
Hi @sorenmalling,
Sorry to get back at you so late, I've been testing with these settings and it seems that if you set a default (true
/1
) on $GLOBALS['TYPO3_USER_SETTINGS']['columns']['hideYoastInPageModule']
it's not possible for a user to "uncheck" it and thus allow the snippet preview to render.
If you don't want the snippet preview to render at all, couldn't you fix this with the tsconfig setting? https://docs.typo3.org/p/yoast-seo-for-typo3/yoast_seo/10.0/en-us/Configuration/SnippetPreview/Index.html#disable-snippet-preview-with-pagets
Or could you describe your use case when this would be useful?
Please give us a description of what happened.
The
YoastUtility
methodsnippetPreviewEnabled
https://github.com/Yoast/Yoast-SEO-for-TYPO3/blob/c1e4ae93d7de523696a5d94cad19154237813e27/Classes/Utility/YoastUtility.php#L51 does not take the default value of the TYPO3_USER_SETTINGShideYoastInPageModule
into account and expect that snippet is enabled.Please describe what you expected to happen and why.
I'd expect the utility to take the default value into account in the condition, so it first checko the
uc
of the user and fallback to the default valueAnd set a default value in ext_tables.php for backward compability
How can we reproduce this behavior?
hideYoastInPageModule
totrue
uc
field, untill the user clickssave
Technical info