Accessory

Archived
Forum
(read-only)

morePreview

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Christopher Imrie

     

Tip: Break out of freames when in preview

General

Nuno Albuquerque
Nuno Albuquerque

I came across a workflow issue while using the morePreview extension and and “edit this” type feature.

A user could click on the edit this link, which would take him to the Publish Entry screen.

Clicking save would show the morePreview.

If the user were to click within the preview and yet again click edit this, they would be in the CP > Preview iFrame > CP.

So, I added a bit of js to break out of frames and wrapped it in a conditional that only shows to users who are logged in and of a certain member group (ie superadmins and content managers)

{!-- Break out of frames when running in frames (morePreview LiveLook in CP) --}
{if logged_in_group_id 
== "1" OR logged_in_group_id == "6"}
[removed]
    
$(document).ready(function (){
        
// only run this if we're within frames
        
if (top.location != self.location{
            
$('a').click(function (){
                  top
.location = $(this).attr('href');
            
})
        
}
    }
)
[removed]
{
/if} 
Nuno Albuquerque
# 1
Nuno Albuquerque

Just to be clear, the JS goes some where in the site template.

Although it would make for a nice feature to automatically do this.

Moresoda
# 2
Moresoda

Thanks for the tip. We’ll add this as soon as we can.