flowblock显示在Admin视图中,而不是contentpage



我对Lektor并不陌生,但我最后一次使用它是在几年前。现在我有一个问题,即flowblock显示在管理视图中,但不在内容视图中。

speisekarte.html
{% extends "layout.html" %}
{% block title %}{{ this.title }}{% endblock %}
{% block body %}
<nav>
<table class="nav navbar-nav">
<tr>
{% for href, title in [
['/speisekarte', 'Salate'],
['/speisekarte/vorspeise', 'Vorspeise'],
['/speisekarte/suppen', 'Suppen'],
] %}
<td{% if this.is_child_of(href) %} class="active"{% endif
%}><a href="{{ href|url }}">{{ title }}</a></td>
{% endfor %}
</tr>
</table>
</nav>
<!--<h2>{{ this.title }}</h2>-->
{{ this.body }}
{% for blk in this.demo_flow.blocks %}
<div class="block block-{{ blk._flowblock }}">
{{ blk }}
</div>
{% endfor %}

speisekarte.ini
[model]
name = Speisekarte
label = {{ this.title }}
[fields.title]
label = Title
type = string
[fields.salat]
lable = Salat
type = flow
flow_blocks = Text Block
gericht.html
<div class="text-block text-block-{{ this.class }}">
{{ this.text }}
</div>
gericht.ini
[block]
name = Text Block
button_label = Text
[fields.text]
label = Name
type = markdown
[fields.preis]
label = Preis
type = markdown
[fields.inhalt]
label = Inhalt
type = markdown
[fields.class]
label = Class
type = select
choices = centered
choice_labels = Centered
default = centered

this.demo_flow.blocks不应该是this.salat.blocks吗?

也可以为每个块定义一个模板文件:

templates/blocks/block-text.html:

<div class="block block-text">
{{ this.content }}
</div>

,然后,在你的主模板只是使用{{ this.salat }}流,这将分别呈现所有的流块。

最新更新