Edit Entry & Page Links in Movable Type

| No Comments

Previously, I wrote about how to add Edit Links to Entry and Page templates.

This guide uses the mt_user cookie set when logging into Movable Type to condition content (links to screens in MT) on entries and pages published by Movable Type.

Also provides an option to use a non-MT cookie to do the same thing.


  • published pages are executed as PHP. Because of this if this code is to be used

Note: this same info can be adapted to create a purely javascript-based solution.

Adding Edit Entry and Edit Page Links

  1. Update the config file (mt-config.cgi) with the CookiePath config directive:

    CookiePath /

    Note: If Movable Type is set up to publish to multiple domains then this won’t work for you

  2. Create a system level template module called “Global Config” and the following content:

    <mt:Unless name="system_template">
        <mt:SetVarTemplate name="edit_link">
            <?php if (isset($_COOKIE["mt_user"])) {?>
                [<a class="edit-link" href="<$mt:CGIPath$><$mt:AdminScript$>?__mode=view&_type=<mt:If name="entry_archive">entry<mt:Else>page</mt:If>&id=<$mt:EntryID$>&blog_id=<$mt:EntryBlogID$>">Edit</a>]
            <?php } ?>

    Note: The archive template variablesystem_template” is used to condition the links to only display on statically published files.

  3. Add the edit links to Movable Type templates.

    For Entry and Page archive templates, just add this anywhere.

    <$mt:Include module="Global Config"$>
    <$mt:Var name="edit_link"$>

    For <mt:Entries> or <mt:Pages> loops in index or archive templates:

    <$mt:Include module="Global Config"$>
        <$mt:Var name="edit_link"$>
        <!-- other entry tags -->

    Note: The include for the “Global Config” module only needs to be added once per template. I suggest placing it as the first line in the template.

  4. Republish all edited templates.

  5. View your blog templates to see the cookie-conditioned code.

Links to other Movable Type App Pages

To add links to:

  • new entry
  • manage entries
  • manage templates
  • rebuild blog

  • Place this code on any page that you’d like to have links to:

    <?php if (isset($_COOKIE["mt_user"])) {?>
        <div class="edit-links">
            (<a href="<$mt:AdminCGIPath$><$mt:AdminScript$>?__mode=view&_type=entry&blog_id=<$mt:BlogID$>">new</a> /
            <a href="<$mt:AdminCGIPath$><$mt:AdminScript$>?__mode=list_entry&blog_id=<$mt:BlogID$>">manage</a>)
            <a href="<$mt:AdminCGIPath$><$mt:AdminScript$>?__mode=list&_type=template&blog_id=<$mt:BlogID$>">templates</a>
            <a onclick="doRebuild('7');return false;" title="Publish Site" href="javascript:void(0)">rebuild</a>
    <?php } ?>
  • To use the rebuild add this to your Javascript index template in Movable Type:

    var CMSScriptURI = "<$mt:AdminCGIPath$><$mt:AdminScript$>";
    function doRebuild (blogID, otherParams) {
        window.open(CMSScriptURI + '?__mode=rebuild_confirm&blog_id=' + blogID + '&' + otherParams, 'rebuild_blog_' + blogID, 'width=400,height=400,resizable=yes');

    If your javascript template is not published by Movable Type, then replace “<$mt:AdminCGIPath$><$mt:AdminScript$>” with the path to the Movable Type application script “http://www.your-domain.com/cgi-bin/mt/mt.cgi

Use a non-MT Cookie

  1. Place this in your MTML template

    Entry edit links are <strong><?php echo (isset($_COOKIE["show_edit_links"]))? "on":"off" ?></strong> &nbsp; (<a id="toggle-edit-links" href="/cheat-sheet/">turn <?php echo (isset($_COOKIE["show_edit_links"]))? "off":"on" ?></a>)
  2. Add jQuery
  3. Add the “Cookie” jQuery plugin
  4. Place jQuery javascript code in a jQuery-enabled js file.

    $('#toggle-edit-links').click( function () {
        var cookieName = "show_edit_links";
        if ($.cookie(cookieName))
            $.cookie(cookieName, null,   { expires: -1,  path: '/', domain: '.th.strangecode.com' })
            $.cookie(cookieName, 'true', { expires: 365, path: '/', domain: '.th.strangecode.com' });
        // refresh window
        window.location = window.location;

Leave a comment