They Call Me Marty!
Design goodness and other ramblings.

Posted on February 10th, 2010 3 Comments

True Entry Preview In ExpressionEngine

ExpressionEngine's Entry Preview

One of the gripes I have with ExpressionEngine is that it doesn’t give you a true preview of an entry. ExpressionEngine will show you the content inside of the control panel, but it is not a representation of what it will visually look like on your site. In order to see what your entry is actually going to look like you have to set the status to “open” and view your entry on your live site. That means having to release your entry into the wild, without being sure if you like how it looks. You can use Leevi Graham’s LG Live Look extension to give ExpressionEngine the ability to display a true preview of an entry, but I don’t think the extension has been ported over to EE 2.0. I will show you a way to get around this using ExpressionEngine’ conditional tag if and a custom entry status. 

The Problem

The problem with setting an entry’s status to “open” when you only want to see what it’s going to look like, is that it becomes viewable to anyone who happens to be browsing your site at that moment.

The Solution

Using ExpressionEngines’ “Custom Entry Status” and the if conditional tag, you can tell ExpressionEngines to display entries with a custom status only to you and only if you are logged in (which you probably will be if you are writing/editing an entry). This is how you do it.

  1. In ExpressionEngines 2.0, go to Admin>Channel Administration>Custom Status Groups and add a new status—I named my new status “Preview,” but you can name it what ever you want.
  2. Create a new entry and set the status to “Preview” (or what ever you called the new status you created in step 1).
  3. In your template, duplicate the exp:channel:entry tag that displays the entries and add a status=“preview” parameter.
  4. All you have to do now is wrap the duplicated channel:entries tag with a conditional if statement, like this if username == “your_username”.

Now you can publish your entry and preview it on your site without anyone else seeing your work in progress.

3 Comments


avatar

On February 16th, 2010 at 4:30 AM

MarmaladeToday thought that:

You should also be able to get an in context view of your post in an appropriate template by using the ‘Live Look’ functionality EE provides.

Edit the preferences for the weblog/channel you want to be able to preview to select whichever template you want to use to ‘Live Look’ that weblog/channel, and then a ‘Live Look’ link should appear on your Edit screen in the control panel under the View column for those entries. Clicking on that should show your entry in all its glory, in the template you’ve specified.

That said, I’ve also used the technique you outline sometimes.

avatar

On September 27th, 2010 at 4:08 AM

Leevi Graham thought that:

I created an addon quite some time ago that took your approached and super charged it a bit. My addon adds a new custom tab and loads the preview inside of that. You never have to leave the CP!

Here’s the link for the EE2 version: http://expressionengine-addons.com/nsm-live-look It allows multiple customisable preview urls unlike the standard EE Live Look.

avatar

On December 13th, 2010 at 9:47 AM

Tyler Herman thought that:

A nice and simple technique. Could also see using this for showing clients work or anyone who needs to see something most people viewing your site don’t need to see, just give them a guest login.


What do you think?

Are you human?

Enter the image you see above