在阅读了http://docs.sulu.io/en/latest/cookbook/live-preview.html和交叉example.html.twig之后,我仍然找不出为什么爱的预览在我的模板中不起作用。
我的模板层次结构(使用主题包):
简而言之,这个结构就像:
bs_homepage.html.twig (只设置一些参数并调用主模板)
{% extends "DWBNFrontendBundle:main:main.html.twig" %}main.html.twig
{% 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
[...]
<body>
<!-- content -->
{% block content %}{% endblock %}
<!-- /content -->
[...]
</block>以及xml定义:
bs_homepage.xml
<?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
<?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>但是如果我更改标题,预览窗口中什么都不会发生。
发布于 2019-01-11 14:13:29
首先:在您的问题中,我看不出您的属性在xml中是否命名为"title“。
但我认为问题是,当最初呈现时,h1 html节点不存在。因此,对此节点的更新根本不可能发生。
尝试添加如下内容:
<div property="title">
{% if content.title %}
<h1>{{ content.title }}</h1>
{% endif %}
</div>https://stackoverflow.com/questions/54147879
复制相似问题