首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sulu 1.6:自定义模板的实时预览无法工作

Sulu 1.6:自定义模板的实时预览无法工作
EN

Stack Overflow用户
提问于 2019-01-11 13:53:12
回答 1查看 305关注 0票数 1

在阅读了http://docs.sulu.io/en/latest/cookbook/live-preview.html和交叉example.html.twig之后,我仍然找不出为什么爱的预览在我的模板中不起作用。

我的模板层次结构(使用主题包):

  1. bs_homepage.html.twig,扩展:
  2. main.html.twig,扩展:
  3. master.html.twig

简而言之,这个结构就像:

bs_homepage.html.twig (只设置一些参数并调用主模板)

代码语言:javascript
复制
 {% extends "DWBNFrontendBundle:main:main.html.twig" %}

main.html.twig

代码语言:javascript
复制
 {% block content %}
     [...]
     <div id="content" class="container" vocab="http://schema.org/" typeof="Content">
          [...]
          <div class="row">
                [...]
                <section class="col-sm-{{ mainCollSize }} main-content" id="content" vocab="http://schema.org/" typeof="Content">
                {% if content.title %}
                     <h1 property="title">{{ content.title }}</h1>
                {% endif %}

                [...]
          </div>
     </div>
 {% endblock %}

master.html.twig

代码语言:javascript
复制
  [...]
  <body>
      <!-- content -->
      {% block content %}{% endblock %}
      <!-- /content -->

      [...]
  </block>

以及xml定义:

bs_homepage.xml

代码语言:javascript
复制
<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xi="http://www.w3.org/2001/XInclude"
          xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.1.xsd">

    <key>bs_homepage</key>

    <view>DWBNFrontendBundle:templates:bs_homepage</view>
    <controller>SuluWebsiteBundle:Default:index</controller>
    <cacheLifetime>2400</cacheLifetime>

    <meta>
        <title lang="de">Startseite</title>
        <title lang="en">Homepage</title>
    </meta>

    <properties>

        <xi:include href="fragments/content-core.xml" xpointer="xmlns(sulu=http://schemas.sulu.io/template/template) xpointer(/sulu:template/sulu:properties/sulu:section[@name='highlight'])"/> 
        [...]
    </properties>
</template>

fragments/content-core.xml

代码语言:javascript
复制
<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.1.xsd">

    <properties>

        <section name="highlight">
            <properties>
                <property name="title" type="text_line" mandatory="true">
                    <params>
                        <param name="headline" value="true"/>
                    </params>

                    <tag name="sulu.rlp.part"/>
                </property>
                [...]
            </properties>
        </section>
    </properties>
</template>

但是如果我更改标题,预览窗口中什么都不会发生。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-11 14:13:29

首先:在您的问题中,我看不出您的属性在xml中是否命名为"title“。

但我认为问题是,当最初呈现时,h1 html节点不存在。因此,对此节点的更新根本不可能发生。

尝试添加如下内容:

代码语言:javascript
复制
    <div property="title">
        {% if content.title %}
            <h1>{{ content.title }}</h1>
        {% endif %}
    </div>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54147879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档