3

Something like this?

{% if craft.session.isLoggedIn %}
    {% set slug = craft.request.lastSegment %}
    {% set entry = craft.entries.slug(slug).status(null).first %}
{% endif %}

{{ entry.title }}

But I get error page not found.

  • Non of this Twig code can cause a 404 page not found error, so you should rather check your routing, Johannes. – carlcs Dec 3 '14 at 8:04
3

If you're specifically checking for the admin, then it's more like:

{% if currentUser.admin %}
    {% set slug = craft.request.lastSegment %}
    {% set entry = craft.entries.slug(slug).status(null).first %}

    {{ entry.title }}
{% endif %}

If you're getting a 404, then it's some other routing issues that is occurring.

  • Looked at apply this to "any" user - {% if user %} but if the entry is disabled then I can't see anything at all. Tried also {% if entry.status == "['disabled', 'live']" %} STUFF {% endif %} but can't get that far. – Simon Clayson Jan 8 '15 at 10:10

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.