Custom block preview when viewing stack in dashboard?

Permalink
Is it possible to have an alternate layout for a block that is in a stack, when you are editing the stack contents? I have a complex layout on my page that is not rendering well in the stack editor.

I know you can create a PHP file in the blocks folder for a different layout when viewing something copied to the clipboard. Is there anything similar for blocks in stacks?

jmcgarvey
 
jmcgarvey replied on at Permalink Best Answer Reply
jmcgarvey
In case anyone else is looking for a solution to this, in your custom block view, you can detect if you are 1) in the dashboard, and 2) if you are viewing the stack:

<?php
$isDashboard = false;
$isStacks = false;

if (Page::getCurrentPage()->getCollectionPath() == "/dashboard/blocks/stacks") {
$isDashboard = true;
}

if (strpos(Page::getCurrentPage()->getCollectionPath(), '!stacks') !== FALSE) {
$isStacks = true;
}
?>

Note that "$isStacks" will not be true until you edit a stack block and save it to the stack, so you need both isDashboard and isStacks:

if ($isDashboard == true || $isStacks == true) { ?>
... do this ...
<?php } ?>
AccountDisabled replied on at Permalink Reply
Perfecto! Thank you so much for this!