We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt custom block type, like (cache, macro.. )


I am trying to create a block like shopify:

{% schema %}
    "name": "Slideshow"
{% endschema %}

How would I create my own block type like this? And is it possible to return this string to the controller IF in dev mode ( Just a variable that is true)

Would I need to edit the C-extension of phalcon or is there a smart way of doing this? :-)

I'm pretty sure you'd have to edit and build your own version of Phalcon (which is technically written in Zephir, not C).

You might be able to get away with just using a partial:

{{ partial('/path/to/partial/file',['name':'Slideshow']) }}


I am looking for a way, to make it possible for theme designers, to do this user friendly.

Maybe Volt is not suitable for this, I took a look at Twig, and that might be better for this project.

Theme designers will be making their own .volt or .phtml files, and have access to the functionality of Volt. I don't see a practical difference between bringing in some view code using custom blocks vs partial.

Obviously it's your choice, but if I were doing this, I'd stick with a built-in solution that gives you what you need. Less code to handle & debug then.