<p>The problem was my attempt to ajaxify the page.</p>

<p>I had my block content wrapped around
<code>{% if not craft.request.isAjax %}</code></p>

<p>the page also gets loaded in via Ajax into the control panel, I changed the code to:<br>
<code>{% if not craft.request.isAjax or craft.request.isLivePreview %}</code></p>

<p>Now it works.</p>

CC BY-SA 3.0
2014-09-09T08:43:37.563Z
2014-09-09T11:45:16.797Z
2014-09-09T11:45:16.797Z
nexflo
<p>I'm using <code>{% block content %}</code> and a main layout file.</p>

<p>When using live preview the "entire" frame isn't shown (including layout files).</p>

<p>Is there an easy way to get the whole template in?</p>

CC BY-SA 3.0
2014-09-03T22:47:54.760Z
That's strange, because live preview should be working with Twig extends. Does this template load ok for you if you access it outside of live preview? Any errors if you enable dev mode?
carlcs
CC BY-SA 3.0
2014-09-04T13:33:18.343Z
Yup, loads just fine.
The structure is: i have one _layout.html with a     
{% block content %}{% endblock %}

and in the pages folder i got the corresponding pages i.e. _news.html which have all content inside 

{% block content %}
    content goes here
{% endblock %}
nexflo
CC BY-SA 3.0
2014-09-04T13:43:01.450Z
Can you post more code and tell us more about what is shown in live preview (what's that entire frame and what do you mean with including layout files)?
carlcs
CC BY-SA 3.0
2014-09-06T12:02:10.037Z
Live preview definitely works with twig blocks, I've got it working on all my sites. You'll need to post your template code to get it looked at in more detail
darylknight
CC BY-SA 3.0
2014-09-09T08:32:37.590Z
Ah i think i found out why. (this kinda correlated with my localized templates question)

I created a pages/_entry.html which loads all the subpages according to some variables...

{% extends "_layout" %}

{% block content %}

         {% include ["pages/_#{entry.type}", "pages/_#{entry.slug}.html", 'pages/_default.html'] %}

        {% endif %}


{% endblock %}

Could it be that craft loads the page directly...and not the way its loaded in the frontend? That way the extend of layout is no longer visible. Guess i could check in every template if its a preview and extend again from _layout
nexflo
<live-preview>
Live Preview and Twig blocks
# Live Preview and Twig blocks

(Asked by: username_0 on 2014-09-03)

I'm using `{% block content %}` and a main layout file.

When using live preview the "entire" frame isn't shown (including layout files).

Is there an easy way to get the whole template in?

**Tags:** live-preview

> **Comments:**
> **username_1**: That's strange, because live preview should be working with Twig extends. Does this template load ok for you if you access it outside of live preview? Any errors if you enable dev mode?  
> **username_0**: Yup, loads just fine. The structure is: i have one _layout.html with a      {% block content %}{% endblock %}  and in the pages folder i got the corresponding pages i.e. _news.html which have all content inside   {% block content %}     content goes here {% endblock %}  
> **username_1**: Can you post more code and tell us more about what is shown in live preview (what's that entire frame and what do you mean with including layout files)?  
> **username_2**: Live preview definitely works with twig blocks, I've got it working on all my sites. You'll need to post your template code to get it looked at in more detail  
> **username_0**: Ah i think i found out why. (this kinda correlated with my localized templates question)  I created a pages/_entry.html which loads all the subpages according to some variables...  {% extends "_layout" %}  {% block content %}           {% include ["pages/_#{entry.type}", "pages/_#{entry.slug}.html", 'pages/_default.html'] %}          {% endif %}   {% endblock %}  Could it be that craft loads the page directly...and not the way its loaded in the frontend? That way the extend of layout is no longer visible. Guess i could check in every template if its a preview and extend again from _layout  

---

## 1 answers

### Answer by username_0 on 2014-09-09. Score: 2

The problem was my attempt to ajaxify the page.

I had my block content wrapped around
`{% if not craft.request.isAjax %}`

the page also gets loaded in via Ajax into the control panel, I changed the code to:  
`{% if not craft.request.isAjax or craft.request.isLivePreview %}`

Now it works.


---

