Edit Links for Entry and Pages

| 3 Comments

Update: Advanced version using cookies to condition “edit” links

Add an edit links to your Movable Type entries and pages.

Edit Entry

<a href="<$mt:CGIPath$><$mt:AdminScript$>?__mode=view&_type=entry&id=<$mt:EntryID$>&blog_id=<$mt:EntryBlogID$>">Edit</a>

Edit Page

<a href="<$mt:CGIPath$><$mt:AdminScript$>?__mode=view&_type=page&id=<$mt:EntryID$>&blog_id=<$mt:EntryBlogID$>">Edit</a>

Tips

  • Add style="text-decoration: none" to the anchor tag to ensure that there is no default link styling
  • Instead of the word “Edit” use an non-breaking space “&nbsp;” and the link will be clickable but invisible

3 Comments

Thanks for the tip.

Is there a way to do it that one wouldn’t have to “hide” the link? E.g., the code tests to see if you’re a logged-in author/administrator and only shows the link if you are? Obviously, this would require some javascript, but it seems more secure.

Yes, it’s possible. I’ve not done it though.

Two ways:

  1. use php to check if cookie is set and then display the link if set.
  2. use javascript to create and display the link if logged in.

I’ll post again if I create a this solution. =)

I do this with just about every project I work on. The key is setting your CookiePath config directive to the common ancestor of both your MT_HOME directory and your blog or site root. That way, the cookie can be seen from the published blog pages.

After that, it’s simply a matter of checking for $_COOKIE['mt_user'] and it’s expiration timestamp. Through this method, you could either conditionally hide/show edit links OR, even more interesting, implement private reading of site/blog content.

Leave a comment