Open hidden article as logged in admin


what is the best case to achieve the following:
I want to set some pages as hidden as i am writing the content, but i want to display a preview.
I dont want to use the preview Plugin i found here, as i am using 100% width of the browser and i need to see how the choosen page reacts.

So, how do i get the current logged in Panel User and check if he is an admin?

If the clause is fault i could redirect to the 404 Page.

Thank you!

A simple if statement:

if(($user = $site->user()) && $user->isAdmin()):
  // show page
  // bye-bye
1 Like

Thank you.
Is what i plan “best case” or something else like a kirby standard?

That’s perfectly fine. If you don’t want these pages to be permanently hidden, you might use a field in your page instead to check if the page is published or not and react on that, so that later you don’t have to change the template but only the field value. Depends on your use case.

1 Like

Okay, i will implement that code now.

Thank you, like always :wink: