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?

  • 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 Sep 3 '14 at 22:47
  • 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 Sep 4 '14 at 13:33
  • 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 Sep 4 '14 at 13:43
  • 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 Sep 6 '14 at 12:02
  • 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 Sep 9 '14 at 8:32

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.