The whole page is disabled in the backend. Like in this screenshot: enter image description here

Now I can't see anything in the Live Preview.

My code starts with: {% for entry in craft.entries.section('aboutus') %}

If I set .status(null) I see everything in the Live Preview, but also the entries which are disabled.

So is it possible to show a disabled page in a Live Preview but not the disabled entries of this page?


In the Live Preview I can see all outside of this for loop {% for entry in craft.entries.section('aboutus') %} but nothing inside.

I uploaded my code here.

  • Is entry your actual variable? Craft actually defines entry as the current entry so if you're trying to use some of the current entry's data inside the loop, you'll get whatever entry the for loop is iterating over (and possibly a syntax error). You might want to change that to aboutUsCurrentEntry or something. I know Live Preview uses the entry variable as well so you might be bumping up against a conflict there... May 24 '16 at 23:09
  • Thanks, but this does not changes anything. Do you have an other idea? May 25 '16 at 18:08
  • It would help to show what code is in your for loop. May 25 '16 at 18:09
  • I uploaded it here: jsfiddle.net/zoy2hj0c May 25 '16 at 18:13

This should do it:

    {% if craft.request.isLivePreview() %}

        {# if it's Live Preview, grab even the disabled entries #}
        {% set entries = craft.entries.section('mySection').status(null).find() %}

    {% else %}

        {# not Live Preview, so just grab enabled entries #}
        {% set entries = craft.entries.section('mySection').find() %}

    {% endif %}

    {% for entry in entries %}
        <li>{{ entry.title }}</li>
    {% endfor %}
  • Thanks for your answer! Now I see everything in the Live Preview, but also the entries which are disabled. So is it possible to show a disabled page in a Live Preview but not the disabled entries of this page? Jul 2 '16 at 10:12
  • .status(null) controls whether it will grab disabled entries or not, so you can take that out if you only want enabled. But if you do that, then this whole thing is pointless because that's the default behavior.
    – Brad Bell
    Jul 2 '16 at 16:22
  • Okay so in the Live Preview it is not possible to see if an matrix entry in a disabled page is activated or not? Jul 3 '16 at 12:56
  • I guess I'm not following. What's a "matrix entry"? Do you mean you want to check if a Matrix custom field has a block that is disabled on a Live Preview request?
    – Brad Bell
    Jul 4 '16 at 3:45
  • 1
    You're probably running into this bug, then: feedback.craftcms.com/forums/285224-bugs/suggestions/…
    – Brad Bell
    Jul 4 '16 at 16:23

You can combine .status( null ) with the isLivePreview property on craft.request. More info can be found in the docs.

  • Yes I know, but so I see in the Live Preview also the entry's which are disabled. But I want to see in the Live Preview the page(whether it's disabled or not) and only the enabled entry's. You know what I mean? May 22 '16 at 13:42
  • Jonathan: it sounds like you have other issues? The live preview will work on any entry, disabled or not, as long as it has a template associated with it. Your template code determines what happens when you want to show other entries. If your live preview isn't working, the template code on that page might be throwing an error, which may be why you're not getting the live preview. May 22 '16 at 22:41
  • Sorry I see you can misunderstand my question. I just updated it May 24 '16 at 19:45

Jonathan, you have a lot going on with your code, including nested for loops, which is probably beyond the scope of the Q&A format here.

If it were me, I'd try to simplify what you have until you get the basics working. If Live Preview isn't working, there's probably other things going on with your code.

Make a copy of your code and do a simple for loop just to start for troubleshooting:

{% for currentEntry in craft.entries.section('aboutus') %}
{% endfor %}

That will spit out the title of the entry and only display the entries that are enabled. If that works, then you keep building up from there until you find the source of what's going on.

  • Thanks for your answer! I tried your code and it's the same result. If the page is enabled I can see the first entry. If the page is disabled I can't see anything. An idea what the error can be? There is also nothing in the error log. Jun 8 '16 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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