tips and tricks for movable type
edit link for entries with PHP
October 12, 2002
Brenna gave me this nifty tip for having edit links for your entries appear on your pages - but visible only to you.
First, you need to create a page to enable you to set an edit cookie (replace yourdomain.com with your domain name, no "www" required):
setcookie ('edit', "", time() - 3600);
setcookie('edit',password,time()+(86400*365),'/');
setcookie('edit',password,time()+(86400*365),'/','.yourdomain.com');
?>
Tip: I used an MT Template Module to create the cookie page, putting the path and filename I wanted in "link this template to a file", and the code in the Module Body window. When I click on SAVE, the file is created for me on my server.
Now, browse to the page you just created to set the cookie.
Next, you need to put the code for the Edit Link where you want it to appear - inside your MTEntries tags if on pages other than Individual. I put mine right after the <MTEntryTitle> tag.
$edit_link = '<a href="<$MTCGIPath$>mt.cgi?__mode=view&_type=entry&id=<$MTEntryID$>&blog_id=<$MTBlogID$>" target="_new">[edit]</a>';
if ($HTTP_COOKIE_VARS['edit'] == 'password') {
echo $edit_link;
}
?>
Rebuild your pages. If you have the cookie, you see the link when you view your pages. If you don't, it's invisible!
(Note that you do not have to replace "password" with an actual password in any of the places where it appears.)
Related Links:
TrackBack: 9
(URL: http://www.thegirliematters.com/sf/mt-track.cgi/103)
» Edit from your main page
Excerpt: Girlie shares how to place an [edit] link within each entry on your index page, that only you can see,
Weblog: Etc.
Tracked: 11.01.02 08:19 AM
» YMDI/MT Quickies
Excerpt: (These are just for me and Jean) [edit] bookmarklet. Jean will put this in our templates, and it will make it very easy for us to edit posts from within our browsers Developing Moveable Type plug-ins This will allow us to keep our members separate form...
Weblog: mediarights staff
Tracked: 07.28.03 02:56 PM
» Edit link for blog authors
Excerpt: [the girlie matters]...
Weblog: Considered...Found
Tracked: 09.06.03 08:14 PM
» Smart "Edit This Entry" Links in Movable Type
Excerpt: As any Movable Type weblog software user knows, finishing a post only to realize when viewing the page that there...
Weblog: Flexistentialist
Tracked: 09.12.03 01:38 AM
» edit entry with cookie
Excerpt: Flexistentialism * Smart "Edit This Entry" Links in Movable Type - uses the "remember me" cookie that MT sets to...
Weblog: lovelinks
Tracked: 09.12.03 04:03 AM
» Movable Type hacks
Excerpt: This has been on my list for a while, and now that it’s implemented it’s certain to be something I’ll use daily. Note: this requires PHP to implement. What I’ve done is pretty straightforward: to visitors, nothing has changed. B...
Weblog: tins ::: Rick Klau's weblog
Tracked: 12.14.03 08:28 PM
» Edit this entry with PHP
Excerpt: in order of appearance, latest via ETC.
Weblog: Gwen Harlow resources
Tracked: 02.10.04 03:21 PM
» edit this link movable type cgi-bin madness
Excerpt: So, recently I decided to add some front end editing tags for MT, so that authors on the MT installs I maintain can just click on a link and be taken to the edit screen within Movable Type. This is...
Weblog: joe mullins dot com
Tracked: 05.26.04 01:59 PM
» Quick Edits
Excerpt: I'm sure that others like Scriptygoddess have posted ones like this, but it just stuck me all of the sudden while I was combing through posts for nasty icky spelling errors. If you post the following URL in a link...
Weblog: This Blog Is Full Of Crap
Tracked: 07.13.04 09:15 AM
Comments
Oh, that's a great way to do it too - I was using the IP address to check, but last week, my ISP changed my IP address, so I had to change my code. This would be preferred because as long as I was on the same browser, it would work :)
is there an easy way to unset the cookie if you want to later?
Sure, another page with the following:
setcookie('edit',"",0,'/','.yourdomain.com');
That will essentially set the cookie "edit" to nothing, so the check will fail.
thanks, Jason! :)
Just thought you might want to know, a small modification to this concept, plus a small change to App.pm, and you can use the cookie that MT leaves when you have it remember your login info.
Read about it here:
http://www.flexistentialist.org/archives/000338.shtml
Thanks for giving me the idea. :)