Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

AttachLinks

Summary: Get Attach: links to display by default without the "Attach:" prefix
Version:
Prerequisites:
Status:
Maintainer:
Categories: Uploads

Questions answered by this recipe

How can I get Attach: links to display by default without the "Attach:" prefix?

Description

Add the following lines to your config.php or local customization file:

Markup('Attach', '>img',
  "/\\bAttach:([^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars])/e",
  "Keep(MakeLink(\$pagename,'$0','$1'),'L')");

This will cause Attach:something.txt to appear as "something.txt". If you want the "Attach:" to still appear when creating a new attachment (but not for an existing attachment), also add

$LinkUploadCreateFmt = "<a class='createlinktext'
  href='\$LinkUpload'>Attach:\$LinkText</a><a class='createlink'
  href='\$LinkUpload'>&nbsp;&Delta;</a>";

After this modification, authors can still create links with the "Attach:" displayed by using the double-bracket form of link (i.e., [[Attach:somepage.txt]]).

Notes

This modification has been applied to the Cookbook group on pmwiki.org.

One may also use [[Attach:somepage.txt | sometext]] to get the attachment link shown with another text. ~~hal
Or [[(Attach:)somefile.txt]]

Discussion

For some reason the Attach:\$LinkText above is shown to me on the page as Attach:\PITS. And if one avoids Attach: for existing attachments, the Delta symbol seems superfluous. ~hal

Suggestion for slight modification

To enhance easy understanding for wiki newbies of what the delta is good for, what about adding a title='Update' to the the second link in $LinkUploadCreateFmt? ThomasP

Questions

how can I modify this recipe to work with the double-bracket form of the link, eg

[[Attach:filename with spaces.txt]]

Attach:filename with spaces.txtΔ

Contributors

  • Pm, 2004-12-20
Edit - History - Print - Recent Changes - Search
Page last modified on May 23, 2008, at 06:32 PM