EpicKau - Is it intended that nested component ...
# ❓questions
e
Is it intended that nested component blocks need a second preview/render file located under /views/site/blocks/ ?

https://cdn.discordapp.com/attachments/811986149064441927/1096882262265561259/image.png

@ifox 😇
i
Hi @EpicKau please be patient, it's Sunday right now and we've had a long week! Can you clarify? Do you have a text block in your faq block? How do you render blocks at the top level?
ok I think I see what you mean now
the site.blocks folder is configurable
so if in a block component render method you are using another path, you should configure the site.blocks folder to be the same
I think the confusion comes from the fact that before block components there was no render method, so blocks were using the same blade file from the site.blocks folder, in both rendering and previewing contexts.
there's also the ability to configure a mapping between block names and blade rendering files
I think what we should do is that in the case of block components, we should use the render method in both cases
not sure that helps clarify for you. let me know if not
e
@ifox I dont want to be mean sorry 😅 . I gues this is what I mean.
Copy code
I think what we should do is that in the case of block components, we should use the render method in both cases
This sounds like the perfect solution^^ When I manually set the block_views_path the path is right but the name is still wrong (app-ID) . How would I fix this?
Copy code
'block_views_mappings' => [
  'app-text' => 'components.twill.blocks.text',
]
k
Ah.. This is why I'm having issues with nested blocks. All of my blocks are now Component Blocks and my blade templates are not in
site/blocks/...
but rather
components/twill/blocks...
The
render
method from a Block Component does not get used at all when the block is included in a nested block editor. This prevents adding any additional data in the render method.
Perhaps having a way to tell the Block Component to use a custom Block class might be useful?
e
@kerkness do you found a workaround?
k
Not really. @EpicKau The blocks which are intended to be used in nested editors I just converted back to regular blocks instead of block components. This let me use a Block class for customizing forms and data.
Planning on perhaps submitting a feature request to make sure Block components always use their own render function. I did submit a bug/issue but it hasn't gotten any comments yet. I'll convert my blocks back to components when things get ironed out a bit more. Not too worried as using a Block class also works for me.
i
We'll take a look at this asap guys. Thanks for sharing.
e
🔥
h
e
Hell yeah, you guys rocks 🔥
k
Amazing. Thanks for this
I did some tests with this change and found some interesting results. If you dynamically change or defined some public properties in the block component they are not available in the blade template when nested but are when not nested. I commented on the PR with my test https://github.com/area17/twill/pull/2243#issuecomment-1517646609