Create Moveable Type (MT) entry for an album

safire

Joined: 2003-12-31
Posts: 1
Posted: Wed, 2003-12-31 15:00

I recently installed Moveable Type as my homepage along with Gallery to handle all my photos. I've seen other threads that discuss how to get MT to generate the html_wrap files to make Gallery look more like the rest of my site. Great stuff.

The one piece I was interested in was creating an entry in my blog for a photo album that I just created. I modeled a solution after the MT Bookmarklet code to post a new entry without logging in.

In detail, here's what I did:

1. Backed up gallery and MT installations.

2. Modify gallery/albums.php as follows:

- Search for "rename album", you should fine a line that looks like:

 <?php echo popup_link("[" . _("rename album") ."]", "rename_album.php?set_albumName={$tmpAlbumName}&index=$i"); ?>

- Insert the following PHP segment immedieate following the above line (and before the "</span>" which is right after the rename album line in my version)

    <?php 
    $title=$gallery->album->fields["title"];
    $desc = $gallery->album->fields["description"];
    $highlight=$gallery->album->getHighlightAsThumbnailTag();
    $albumUrl = makeAlbumUrl($tmpAlbumName);
    $text=urlencode(rawurlencode("<a href=\"$albumUrl\">$highlight</a><br>\nA new photo album was uploaded: <a href=\"$albumUrl\">$title</a><br>\n$desc"));
    $title=urlencode(rawurlencode($title));
    
    echo popup_link("[" . _("create MT entry") ."]", '../MT/mt.cgi?is_bm=1&bm_show=category,text_more&__mode=view&_type=entry&title='._($title).'&blog_id=1&text='._($text));
    ?>

You'll need to modify the path to 'mt.cgi'. You can also change the default text that is used for the entry.

3. Modify MT/lib/MT/App/CMS.pm as follows:

- Search for 'sprintf'. You are looking for the following code:

  $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
    scalar $q->param('link_title'),
    scalar $q->param('link_href'),
    scalar $q->param('link_title'),
    $param{text};

- Wrap the above in a conditional like below:

   if ($q->param('link_href')) {
    $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
      scalar $q->param('link_title'),
      scalar $q->param('link_href'),
      scalar $q->param('link_title'),
      $param{text};
  }

The bookmarklet code was designed to automatically insert a link to the text selected on the screen. This just skips it if link_href is not defined.

That's it. Now when you view your gallery when logged in, you should see [create MT entry] right after [rename album]. Click on this and you will get a nice dialog with the title filled in and the entry text filled in with the embedded highlight image, the album title, and album description, complete with links to view the album.

If you'd like to see more options in the MT dialog, use the "Set up Bookmarklets" on the MT Main Menu to generate the javascript code that includes all the options you'd like to see, and then modify the "echo popup_link...." line in albums.php to match. I think it comes down to mostly adding to the 'bm_show' parameter.

What I'd still like to accomplish is the ability to set a default Weblog as well as the default category. Looking at the code, looks like it would require more significant changes to the MT code.

...cj