Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add this to a snippet and include that snippet before the </body> tag. Adds an edit link to edit content. Only shows up if you are logged-in your store's admin.
{{ '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' | stylesheet_tag }}
<style>
.edit-tool {
float: right;
position: fixed;
right: 0;
top: 70px;
background-color: white;
padding: 5px 10px;
-webkit-box-shadow: -1px 0px 3px 0px rgba(50, 50, 50, 0.6);
-moz-box-shadow: -1px 0px 3px 0px rgba(50, 50, 50, 0.6);
box-shadow: -1px 0px 3px 0px rgba(50, 50, 50, 0.6);
}
.edit-tool a {
color: #555;
cursor: pointer;
}
</style>
<script>
$(window).load(function() {
if ( $('#admin_bar_iframe').size() ) {
$('body').append('<div class="edit-tool"><a><i class="fa fa-pencil-square-o"></i> Edit this </a></div>').find('.edit-tool a').click(function(e) {
e.preventDefault();
(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.10.1",function($,L){var s=$(location).attr("hostname"),u=$(location).attr("href")+".json";$.ajax({url:u,type:"GET",dataType:"json",success:function(o){if(o.hasOwnProperty("product")){var t=o.product.id;window.location.href="https://"+s+"/admin/products/"+t}else if(o.hasOwnProperty("collection")){var t=o.collection.id;window.location.href="https://"+s+"/admin/collections/"+t}else if(o.hasOwnProperty("page")){var t=o.page.id;window.location.href="https://"+s+"/admin/pages/"+t}else alert("Sorry, but you cannot use this here.")},error:function(){alert("This cannot be used here.")}});});
});
}
});
</script>
@suture

This comment has been minimized.

Copy link

commented Jul 15, 2016

It no longer works on Article pages, now that the URL system has been changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.