KBD

Keith Devens .com

Wednesday, March 17, 2010 Flag waving
The very name "selection" implies that you're choosing between two or more variants. So that means that the end... – Dr. Walter Veith

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 →
March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



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

Recent comments XML

new⇒I hate ASP.NET

I hate ASP... I was doing wonders​with PHP, then suddenly one of my​clients...

Johnies: Mar 17, 6:14am

Quantum physics and free will

I knew you were going to say that....

Tom Massey: Mar 15, 9:26pm

Generated in about 0.051s.

(Used 7 db queries)