【问题标题】:flowblock is shown in Admin view but not contentpageflowblock 显示在管理视图中,但不是 contentpage
【发布时间】:2021-09-11 11:37:39
【问题描述】:

我对 Lektor 并不完全陌生,但几年前我最后一次使用它。现在我遇到了流块显示在管理视图中而不是内容视图中的问题。

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

【问题讨论】:

    标签: lektor


    【解决方案1】:

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

    另外,您可以为每个块定义一个模板文件:

    templates/blocks/block-text.html:

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

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

    【讨论】:

      猜你喜欢
      • 2021-11-21
      • 2020-04-17
      • 1970-01-01
      • 2020-10-31
      • 2023-03-16
      • 2021-08-02
      • 2023-02-14
      • 2019-11-10
      • 1970-01-01
      相关资源
      最近更新 更多