KBD

Keith Devens .com

Sunday, July 20, 2008 Flag waving
There are two ways of constructing a software design; one way is to make it so simple that there are... – C. A. R. Hoare

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 →
July 2008
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



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

Spider solitaire

To answer an earlier question, I am​almost certain every game can be​beat. ...

Jared: Jul 16, 2:20pm

I hate Norton Antivirus

I HATE NORTON ANTIVIRUS IT SUCKS I​GOT AVG IT ROX! AGES TO DELETE​NORTON AN...

wade: Jul 15, 1:44am

Generated in about 0.167s.

(Used 7 db queries)

mobile phone