getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

Extending a core block blueprint from a custom block blueprint #4851

Closed MoritzLost closed 1 year ago

MoritzLost commented 1 year ago

Description

I'm trying to extend a core block blueprint from my own block blueprint. The documentation only mentions extending the core block blueprints in the context of a blocks field, but I would like to have the block blueprint as it's own file so it can be reused. For example, I want to create a file site/blueprints/blocks/quote.yml and extend the blocks/quote.yml blueprint from the core:

extends: blocks/quote
icon: bug

This appears to create an endless loop (the page breaks with a memory size exhausted error). This makes sense, since blocks/quote refers to the template itself. How could I extend the blocks/quote blueprint from the core in this case?

Kirby Version

3.8.1.1

texnixe commented 1 year ago

You could use another name for the block, myquote instead of quote.

distantnative commented 1 year ago

I don't think we will be able to fix this in a sensible way. The defining part of a blueprint here is its name blocks/quote. Extending itself - the blueprint with exactly the same name - will crash most implementations, I'm afraid. To the system, the location of the file doesn't really matter - so it cannot differentiate by it either.

MoritzLost commented 1 year ago

@texnixe Thanks for the suggestion, that sounds like a good workaround!

@distantnative Thanks for the explanation! Maybe there should be a sort of optional namespacing system? For example, allow the system to distinguish between @core/blocks/quote and @user/blocks/quote, and associate those with the blueprint folder of kirby and the site, respectively? This could be completely optional so it's backwards compatible.

Anyway, the suggestion by @texnixe sounds like a good idea, and copying the entire YML file over isn't that bad either. Just wanted to know if I'm missing something here. Maybe consider this as a feature request, having the ability to specify core blueprints specifically sounds like it could be useful in some situations.

lukasbestle commented 1 year ago

@MoritzLost I think your namespacing suggestion makes sense. I'm not sure about the syntax, but I see why explicitly referring to a core blueprint may be useful. Could you please create a feature request on https://feedback.getkirby.com?

I'm closing this issue as the current behavior is not a bug as Nico explained.

MoritzLost commented 1 year ago

@lukasbestle Done! https://kirby.nolt.io/489