1

After reading http://docs.sulu.io/en/latest/cookbook/live-preview.html and also crosschecking the example.html.twig I still can not find out why the love preview is not working in my template.

My Template hierarchy (using the theme bundle):

  1. bs_homepage.html.twig, extends:
  2. main.html.twig, extends:
  3. master.html.twig

In a nutshell the structure is like:

bs_homepage.html.twig (just sets some parameters and calls the main template)

 {% 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>

And the xml definitions:

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>

But if I change the title, nothing happens in the preview window.

Andreas
  • 1,691
  • 1
  • 15
  • 34

1 Answers1

1

First: In your question I can't see if your property is named "title" in your xml.

But I think the problem is when it's initially rendered, the h1 html node does not exists. Therefore a update to this node can't happen at all.

Try to add something like this:


    <div property="title">
        {% if content.title %}
            <h1>{{ content.title }}</h1>
        {% endif %}
    </div>

trickreich
  • 190
  • 1
  • 7
  • I added the xml structure, adding the wrapper div did unfortunately not do the trick. – Andreas Jan 12 '19 at 13:05
  • Actually it did! I had an additional template error, because not all variables are set in the preview update ajax request. – Andreas Jan 13 '19 at 09:48