UpdateAttachments

Summary: Add "update Attachment" link to Attach: links
Version:
Prerequisites:
Status:
Maintainer:
Categories: Uploads

Questions answered by this recipe

Is there a way to get Attach: links to provide an "update attachment" link?

Answer

The formatting of Attach: links is controlled by $IMapLinkFmt['Attach:']. By default this uses the same value as $UrlLinkFmt -- i.e., attachments are rendered the same as any other InterMap or external link. Changing this setting makes it possible to provide custom formatting of Attach: links.

For example, the Cookbook uses the following to automatically provide a quick link for updating its attachments:

  $IMapLinkFmt['Attach:'] =
    "<a class='urllink' href='\$LinkUrl'>\$LinkText</a><a
      class='createlink' href='\$LinkUpload'>&Delta;</a>";

This causes attachments to be displayed as the attachment's text followed by a Greek "delta" (Δ) that links to the upload page for that attachment, as in mimetex.phpΔ.

One can even cause the appearance of these links to be optional. For example, the code below would cause attachments to have an update link added only if ?update=y is added to the page's url:

  if (@$_REQUEST['update']=='y') {
    $IMapLinkFmt['Attach:'] =
      "<a class='urllink' href='\$LinkUrl'>\$LinkText</a>
       <small><a target='_blank' href='\$LinkUpload'>(update)</a></small>";
  }

Furthermore, the target='_blank' causes the upload page to open in a new window. The above code has been activated on this page so you can try it -- see how Attach:mimetex.phpΔ changes when you click UpdateAttachments?update=y.

See Also

Contributors

  • Pm, 2004-12-22