How to turn off the preview window in the administration interface? #5699
-
Sulu, how to turn off the preview window? The preview window can be turned off in the file sulu_admin.yaml: # config/packages/sulu_admin.yaml
sulu_preview:
mode: 'off' |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey, As you already mentioned, the preview can be disabled for the whole project via the symfony configuration (see https://docs.sulu.io/en/2.2/bundles/preview/). You can add this configuration to any file inside of the # config/packages/sulu_preview.yaml
sulu_preview:
mode: 'off' If you want to disable the preview for pages of a single template (eg. the To do this, you can register an additional <?php
# src/Admin/AppAdmin.php
declare(strict_types=1);
namespace App\Admin;
use Sulu\Bundle\AdminBundle\Admin\Admin;
use Sulu\Bundle\AdminBundle\Admin\View\ListItemAction;
use Sulu\Bundle\AdminBundle\Admin\View\ListViewBuilderInterface;
use Sulu\Bundle\AdminBundle\Admin\View\PreviewFormViewBuilderInterface;
use Sulu\Bundle\AdminBundle\Admin\View\ViewCollection;
use Sulu\Bundle\ContactBundle\Admin\ContactAdmin;
use Sulu\Bundle\PageBundle\Admin\PageAdmin;
class AppAdmin extends Admin
{
public function configureViews(ViewCollection $viewCollection): void
{
$previewFormViewNames = [
'sulu_page.page_edit_form.details',
'sulu_page.page_edit_form.seo',
'sulu_page.page_edit_form.excerpt',
'sulu_page.page_edit_form.settings',
];
foreach ($previewFormViewNames as $previewFormViewName) {
if ($viewCollection->has($previewFormViewName)) {
/** @var PreviewFormViewBuilderInterface $viewBuilder */
$viewBuilder = $viewCollection->get($previewFormViewName);
$existingPreviewCondition = $viewBuilder->getView()->getOption('previewCondition');
$viewBuilder->setPreviewCondition(
'(' . $existingPreviewCondition . ') && template != "default"'
);
}
}
}
public static function getPriority(): int
{
return PageAdmin::getPriority() - 1;
}
} |
Beta Was this translation helpful? Give feedback.
Hey,
looks like you already found a solution, so thanks a lot for helping others by posting this!
As you already mentioned, the preview can be disabled for the whole project via the symfony configuration (see https://docs.sulu.io/en/2.2/bundles/preview/). You can add this configuration to any file inside of the
config/packages
directory (you could also create a newsulu_preview.yaml
).If you want to disable the preview for pages of a single template (eg. the
default
template), you can overwrite thepreviewCondition
which is set in thePageAdmin
:sulu/src/Sulu/Bundle/PageBundle/Admin/PageAdmin.php
Line 248 in 7c24e0b