UploadGroups

Summary: Allow uploads to be associated with individual pages or the entire site
Version: n/a
Prerequisites: PmWiki 2.0.0
Status: stable
Maintainer:
Categories: Uploads

Questions answered by this recipe

By default, an attached file (PmWiki.Uploads) is associated with a WikiGroup -- that is, all of the uploads for a particular group are combined in one subdirectory. How can I get uploads to be associated with individual pages or the entire site?

Answer

The organization of attachments/uploads is controlled by the $UploadPrefixFmt variable. By default this variable is set to "/$Group", which places all attached files into subdirectories by group.

To change this so that attachments are organized on a per-page basis, simply add the following to config.php:

    $UploadPrefixFmt = '/$FullName';

You could also specify that:

    $UploadPrefixFmt = '/$Group/$Name';

Like that you'll get a per-group and per-page basis upload.

To have all of the attachments for an entire site placed into a single location (accessible from all groups), use

    $UploadPrefixFmt = '';
Q: In the V1 Cookbook entry there was a slash between the apostrophes, but that generated a double slash in the rendered URL. Do either of '/$Group/' or '/$PageName/' have this problem? -NH
A: Yes, in v2 the trailing slashes are no longer required. I've fixed this above. --Pm

The Attach: markup will be affected by these settings:

For default settings with per group uploads (Group uploads folders):

  • Link to attachments on the same page ### should this be 'same group'? ### with Attach:filename.ext
  • Link to attachments on another WikiGroup with Attach:GroupName./filename.ext

For per page uploads:

  • Link to attachments on the same page with Attach:filename.ext
  • Link to attachments on another page with Attach:GroupName.PageName/filename.ext

For uploads in single location:

  • Link to attachments on any page with Attach:filename.ext

Contributors

Comments

On 2005-01-05 PM mused about changing the Attach: markup to allow cross-group references. It would look something like Attach:groupname./filename.txt

This is available from Pmwiki 2.0.0

On 2007-01-08 E.M. I am trying to manage to set up a per group upload site wide password system but only one group per group/page. I have been reading about this but I can't not manage to do this, do you guys know any way to do this ?


Q: How can I determine the current upload directory/url in a recipe (e.g. during markup for a given page)?

A: This worked for me (Frank November 05, 2009, at 08:32 AM):

  global $UploadDir, $UploadUrlFmt, $UploadPrefixFmt, $ScriptUrl; 
  $pn = ResolvePageName('');
  $upDir = FmtPageName("$UploadDir$UploadPrefixFmt", $pn);
  $upUrl = FmtPageName("$SkriptUrl$UploadUrlFmt$UploadPrefixFmt", $pn);
  

User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.