KBD

Keith Devens .com

Saturday, November 22, 2008 Flag waving
Battle not with monsters lest ye become a monster and if you gaze into the abyss the abyss gazes into... – Friedrich Nietzsche

Archive: April 10, 2004

← April 09, 2004April 12, 2004 →

Daily link icon Saturday, April 10, 2004

lazyweb: Movable Type question (how to do an "Edit this Page" button)

How does Movable Type know when you're logged in? I'd like to modify a friend's blog so that when he's logged in, a little edit button shows up next to each of his Movable Type posts so that he can go right to the MT interface to edit it. His static pages are parsed by PHP, so I can put programming in them. I just need to know how Movable Type knows he's logged in so I can mimic that.

Update: I poked around the source for some minutes, and after getting to some parts where it left cookies I figured I'd just take a look at what cookies Movable Type leaves around when you're logged in. I should have just done that in the first place.

I created a simple PHP script:

<?php
header
("Content-type: text/plain");
print_r($_COOKIE);
?>

And once I discovered, like Dennis pointed out in a comment, that MT leaves a "user" cookie, I just added the following simple code to his main index template right after where his post title is displayed.

<?php
if(isset($_COOKIE['user'])){?>
    <a href="/weblog/mt.cgi?__mode=view
&_type=entry&id=<$MTEntryID$>&blog_id=<$MTBlogID$>">(edit)</a>
<?php ?>

It's really simple logic, and it doesn't test to see if you're really logged into Movable Type or whether there just happens to be a "user" cookie lying around. But, it's good enough, and if for some strange reason my simple code thinks he's logged in when he's not, the link will just go to the Movable Type login page and no harm done.

Note, I split up the URL above so that it doesn't bust out my page layout.

Update (4/13): Edited the title to better reflect its content.

← April 09, 2004April 12, 2004 →
November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

Calif. Supreme Court to take up gay marriage ban

I would argue the point is not​definitional.  While the word​marriage is su...

Justin: Nov 20, 4:37pm

Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Generated in about 0.053s.

(Used 7 db queries)

mobile phone