Closed squareclouds closed 7 months ago
I think the best solution here is to disable the cookie banner for the preview. Does that work for you?
With the release of v1.1.0+, you can now detect the preview mode in both backend and frontend code. There's a dedicated documentation guide.
In summary:
The Kirby Live Preview provides a previewMode
content key that you can use to detect whether the current page is in preview mode. The key is true
if the page is in preview mode and undefined (false
) otherwise:
Wrap the cookie banner snippets that you want to hide in a conditional statement that checks if the previewMode
key is false
:
<?php if ($page->previewMode()->isFalse()): ?>
<?php snippet('cookie-banner') ?>
<?php endif ?>
Alternatively, use the data-preview-mode
attribute to hide or disable elements in your frontend code.
For example, you can hide the cookie banner with the following CSS:
[data-preview-mode] .cookie-banner {
display: none;
}
For JavaScript animations or other features, you can use the data-preview-mode
attribute to disable them:
const isPreviewMode = document.documentElement.dataset.previewMode;
if (!isPreviewMode) {
// Init your cookie banner
}
ah ok, yes that sounds good enough! thank you!
@johannschopplich sorry, dumb question, where can i get 1.1.0? :D i bought the plugin two days ago and i am a bit confused now.
oh i found it now. i always have to click "view order" in the email of my purchase?
Unfortunately, yes. Private Composer repos are more pricey than what I make with this plugin, so I rely on good old ZIP files for now. I hope to find a better solution in the future...
You can then download the latest version from your order page of our payment provider.
Environment
live preview: 1.0.5 kirby: 4.1.2
Reproduction
add a cookie plugin like cookieconsent
Describe the bug
cookie banners keeps popping up, which hides parts of the screen, at least in my case. in other cases it might even disable everything until you accept or decline, which makes the preview pretty much unusable if you have to interact inside the iframe to see anything. any ideas on how to workaround this?
Additional context
No response
Logs
No response