https://twill.io logo
Good afternoon. Tell me how to get a list of block...
# ❓questions
h
Good afternoon. Tell me how to get a list of blocks from blockEditor?
k
Where do you need it? You can get them via
blocks
relation, eg.
Copy code
php
$blocks = Model::find(1)->blocks();
You can dump
$blocks
and see its contents, to get the idea what you need.
h
@kalle Let me describe the problem first. I have a block editor on my site. (I have 126 used blocks created). The problem is that all these blocks are rendered when the page is loaded. Because of this, the admin panel takes a long time to load. I want to sort the blocks so as not to load the extra ones.
k
So basicly you wanna filter them before form page is loaded (render only specific blocks)?
h
On a page where there are no blocks, this is all rendered. I want to at least filter so that the admin panel does not slow down.
Yes, only those that belong to this model. And if there are no blocks on the page at all, then do not render at all
Found this code Here he receives all the blocks and renders them all
when this is rendered we don't know which blocks you are going to allow on a specific form
what you're asking is that this renders only the allowed blocks in each of your form?
h
the problem is that I need to add blocks regularly, and if I change inline_blocks_templates to false, I won't be able to add blocks
And I want, for example, on the "Career" page, only those blocks that belong to the block editor on this page are rendered.
i
yeah, I understand. To explain why this might be challenging: you can use multiple block editor field in the same form, so we would need to combine the list of blocks of all your block editor fields to avoid rendering blocks not used on this page.
we will look into it
126 blocks is a lot haha
I'm curious why you need this many (not judging, just curious)
2 Views