Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error.

Custom blocks

khomutovspace

Hello! Blocks supports styling and template changes, which is very cool for start. But how could they be fully replaced with a custom ones? For example, can I write absolutely new (not based on existing ones) block in my package and provide it as a block options with custom presets and options?


mad

khomutovspace Hi, you can use any snippet as a custom block by using the snippet block. That block also has a little editor field to provide custom configuration using the template language. You can then for example use <@ set { :var: ''value' } @> to configure the loaded snippet. Note that all .php files in any directory called snippets somewhere in a package can be selected in the dropdown.


khomutovspace

Thank you for the answer. I checked this option and I think it can help sometimes, but providing custom snippets can be not always a good idea for an end user. Also I see no way to change manually (from dashboard) any variables especially if I need to repeat one snippet for more than once. So I think it would be a really great option to be able to replace standard blocks with a theme or provide a full variable editor for every snippet block. I don't khow, how difficult it is for you to do, so it's just a suggestion.


khomutovspace

Or maybe it would be a good idea just to provide a custom template option for every type of block, so developer can fully customize it according to theme style.


mad

khomutovspace Yeah, I understand. Basically like the options for pagelist and filelist blocks?


khomutovspace

mad, I think yes. But the main idea of my proposal is to make blocks more customizable. I see that now block settings (not template) realized via clean php in an Automad directory. Understand, why it is made how it is. But don't you think there can be something like an extra variables for custom blocks, for example:
Custom block — card
Custom block settings: @{ !icon }, @{ !title } and @{ !text }
And all these block settings would look the same as usual variables, but not in the page setting, but at exact block. What do you think about it? Is it ok for Automad conception? Is it realistic?


mad

khomutovspace Hi, I like the proposal. However introducing new language elements has to be done carefully to maintain an overall consistency. I understand that such a card actually requires custom configuration as well as custom templates. Therefore your idea makes total sense!

It could be also possible to allow users to define the variables you mentioned in the snippets block UI. What do you think?

A quick workaround for now — until there is maybe a better way — would be to abuse a pagelist for that using a page to just hold the card's content.


khomutovspace

mad Talking about the exact position of this feature, I think it could fit well as a snippet option too. The only way I firstly introduced my idea specifically in connection with custom blocks — is simplicity for the end user: custom blocks provide person exact what is needed (maybe some sites doesn't need some of default blocks) and they are easy to choose, not like a snippets, which shows all the snippets from themes at one time as the list without any icons or images.

Talking about the current solution, I can say that I personally usually just use static templates for these with a fixed amount of cards (or some other elements, you know, it is relevant not only to the cards), which makes me or end user less free.


mad

khomutovspace I agree that it would add more freedom for the users — and that's great. However, to make the toolbar with blocks more configurable would dramatically increase the complexity as well. That's not a problem itself but it requires some developing time.


maakbow

Im making custom templates from scratch, no framework.
What would actually help how i use blocks would be if i could simply turn off certain block types in the tool bar to not have to style the ones that are not usefull for the particular job