Comments (4)
This should work, can you give me more context and post the whole text.twig file and your twig config? Are you on the latest version?
from kirby-twig.
I'm on the last version : 4.1.7.
I made a plugin which define a macro to handle a kind of template suggestion for my blocks :
{% macro ui_blocks(page) %}
{% set blueprint = page.blueprint().name %}
{% for field in page.content().keys() %}
{% include [
'@snippets/blocks/' ~ blueprint ~ '/' ~ field ~ '.twig',
'@snippets/blocks/' ~ field ~ '.twig',
'@snippets/blocks/' ~ blueprint ~ '/default.twig',
'@snippets/blocks/default.twig'
] %}
{% endfor %}
{% endmacro %}
from my page template I call this macro :
{{- ui_blocks(page) -}}
I have a builder block (layout field) ('@snippets/blocks/builder.twig') which also use a template suggestion system :
{% set blueprint = page.blueprint().name %}
{% for layout in page.content.builder.toLayouts() %}
<section>
{% set columns = layout.columns() %}
{% for column in columns %}
<div class="{{ column.span() }}">
{% for block in column.blocks() %}
{% set type = block.type() %}
{% include [
'@snippets/blocks/' ~ blueprint ~ '/' ~ type ~ '.twig',
'@snippets/blocks/' ~ type ~ '.twig',
'@snippets/blocks/' ~ blueprint ~ '/default.twig',
'@snippets/blocks/default.twig'
] with { 'foo': 'bar' } %}
{% endfor %}
</div>
{% endfor %}
</section>
{% endfor %}
So if I add a text block it calls
@snippets/blocks/text.twig
which contains
<div class="prose">
{{ foo }}
{{ page.content.text.kirbytext | raw }}
</div>
My twig configuration is the following :
'amteich.twig.env.functions' => [
// Plugin db-helper
'isHtmxRequest' => 'isHtmxRequest',
'db' => 'db',
'meta' => 'meta',
// Laravel mix
'mix' => 'mix',
],
'amteich.twig.env.filters' => [],
'amteich.twig.env.tests' => [],
from kirby-twig.
I have found the solution. Cleaning some content text files containing old references to a field solved the problem !
Thank you.
from kirby-twig.
Ah good that you found the solution. Thanks for looking into it on your own. I was busy the weekend.
from kirby-twig.
Related Issues (20)
- Custom namespaces not working HOT 1
- Is it possible to include snippets of a php library in a twig file? HOT 7
- Custom namespaces not working in Kirby 3.4.2 HOT 3
- PHP 8.0 Support HOT 3
- References to old repository name (mgfagency/kirby-twig) HOT 1
- Composer install yields InvalidArgumentException HOT 1
- How to use Kirby collections in a twig template HOT 3
- Site not available inside of a block template HOT 6
- Availability of model function in template HOT 3
- Overwriting a default block snippet from inside a plugin does not render the Twig code HOT 4
- How to get a site method defined in a custom plugin ? HOT 1
- Encoding emails with twig HOT 2
- Possibility to render block template in block preview HOT 1
- The documentation for the autoescape option is incorrect HOT 1
- Not compatible with kirby layouts extension HOT 2
- Register new templates? HOT 2
- Global Kirby objects should be added to the environment as globals HOT 7
- E-Mail templates with html/text types don't work correctly HOT 2
- Error with PHP 8.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kirby-twig.