Replies: 1 comment
-
|
It depends what the You'll want to be wary of deleting blocks that are attached to previous versions of an entry however - if your section is enabled with versions. If you wanted to delete them, you'll have to loop through existing blocks and delete them, but that's a bit of a waste of resources unless you really need to delete them. If their content hasn't changed, passing the in block ID as the key would be more efficient. $blocks = $entry->accordions->all();
foreach ($blocks as $key => $accordion) {
// ...
}
foreach ($blocks as $block) {
Craft::$app->getElements()->deleteElement($block);
}By the way, you should use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Are the old super table blocks deleted from the database when updating a super table field like this?
If not, what is the best way to remove old blocks that are not used anymore?
Beta Was this translation helpful? Give feedback.
All reactions