Published by Mijingo

movie icon image

EE Insider Blog

Spend your time learning and developing sites with ExpressionEngine and we'll use this blog to keep you informed of all the news related to ExpressionEngine and CodeIgniter.

» Read more in the Archives.

» Have a tip? Send us your EE news.

Learn ExpressionEngine Today

Over a series of 8 videos, watch and learn as Ryan builds an entire ExpressionEngine website from beginning to end. Get started now.

Using Stash to Create Entry Previews

Over at Meta Q front-end developer Terris Kremer wrote up a tutorial on using the Stash add-on to create entry previews.

Wait, what’s Stash?

Stash allows you to stash text and snippets of code for reuse throughout your templates. Variables can be set dynamically from the $_GET or $_POST superglobals and can optionally be cached in the database for persistence across pages.

Stash variables that you create are available to templates embedded below the level at which you are using the tag, or later in the parse order of the current template.

The premise of the tutorial is that existing methods for creating entry previews are too complicated.

There are a few add-ons and methods out there that let site admins preview their ExpressionEngine entries and they all stink.

I disagree with the premise (the solution with Stash ended up being more complicated) but the tutorial is a great demonstration of what you can do with the Stash add-on by Mark Croxton.

Posted on Apr 10, 2012 by Ryan Irelan

Filed Under: Development Tools, EE Add-ons

Robson Sobral00:07 on 04.11.2012

I just put this code into a snippet and use around all website:

{if status==‘draft’}{if logged_in_group_id != ‘1’}{if logged_in_group_id != ‘5’}{redirect=‘404’}{/if}{/if}{/if}

In this case, I have a group for administrators, 1, and one for authors, 5.

This works really well for me.

Robson Sobral23:29 on 04.16.2012

Improving:

{if status==‘draft’}{if logged_in_group_id != ‘1’}{if logged_in_group_id != ‘5’}{redirect=‘404’}{/if}{/if}{/if}
{if ‘{entry_date}’ > ‘{current_time}’}{if logged_in_group_id != ‘1’}{if logged_in_group_id != ‘5’}{redirect=‘404’}{/if}{/if}{/if}