TC
Twill CMSβ€’2y ago
agnonym

[3.0.0] Block class - getBlockTitle()

Hi, I was trying to move Blade blocks to Class. When I wanted to move @twillBlockTitleField in class, I thought I had to do my own logic in the getBlockTitle() method of my class which is supposed to have the block as argument. But the block is always null, indeed, the only call is in Services\Blocks\Block::parsePropertyFallback() but without arguments 😁 Is this supposed to pass the block ? (as A17\Twill\Models\Block or use A17\Twill\Services\Blocks\Block?)
6 Replies
Hro
Hroβ€’2y ago
it is indeed always null. I know why I added is as an optional argument but never really implemented it I think πŸ€¦β€β™‚οΈ you should be able to still use the method to set a title
public static function getBlockTitle(?Block $block = null): string
{
return Str::replace('Block', '', Str::afterLast(static::class, '\\'));
}
public static function getBlockTitle(?Block $block = null): string
{
return Str::replace('Block', '', Str::afterLast(static::class, '\\'));
}
agnonym
agnonymOPβ€’2y ago
No problem! πŸ˜‰ What I wanted to do is set a title depending on a Block content value like @twillBlockTitleField in Blade forms, but without the Block instance, I don't see how to do it. But maybe is there an other way to do so in Block classes? @hro1337 @ifox.dev sorry to bother you, may you explain me how I can achieve the @twillBlockTitleField feature using a Block class?
Hro
Hroβ€’2y ago
I'll have to check this. Will try to do it in the afternoon
agnonym
agnonymOPβ€’2y ago
Thanks @hro1337, no hurry, I just wanted to not let the subject die. Let me know if I can do something about this
Hro
Hroβ€’2y ago
GitHub
Add title prefix support to component blocks. by haringsrob Β· Pull ...
This pr allows component blocks to set the title prefix and title field: <?php namespace App\View\Components\Twill\Blocks; use A17\Twill\Services\Forms\Fields\BlockEditor; use A17\Twill\Servic...
agnonym
agnonymOPβ€’2y ago
Thx @hro1337 !!
Want results from more Discord servers?
Add your server