[pmwiki-users] $UploadPrefixFmt and Attach files

Dominique Faure dominique.faure at gmail.com
Fri Apr 4 02:52:29 CDT 2008

On Thu, Apr 3, 2008 at 5:12 PM, Hans <design5 at softflow.co.uk> wrote:
> Can anyone please help with this problem?
>  Thanks -
>   Hans
>  Monday, March 31, 2008, 1:53:36 AM, Hans wrote:
>  > I would like to be able to upload in some wiki groups
>  > so the uploaded files are stored in
>  > uploads/$Group/$Name/ folders, and in some groups in
>  > uploads/$Group/ folders.
>  > How do I configure this, and also have the Attach: markup working,
>  > so that Attach:{$Name}.jpg  will work in both cases, i.e. an image file
>  > with the page name as file name will be displayed in the page without
>  > needing a Group/ or Group/Name part.
>  > Setting $UploadPrefixFmt  should set the upload path, but it only
>  > sets it if I also set in config.php
>  > $UploadDir = 'uploads';
>  > $UploadPrefixFmt = '/$Group';
>  > $UploadFileFmt = "$UploadDir$UploadPrefixFmt";
>  > So I tried to do it conditionally
>  > # per group subdirectories
>  > WikiDir = new PageStore('wiki.d/$Group/$FullName');
>  > $group = PageVar($pagename,'$Group');
>  > if ($group=='Special') {
>  >    $UploadDir = 'uploads';
>  >    $UploadPrefixFmt = '/$Group';
>  >    $UploadFileFmt = "$UploadDir$UploadPrefixFmt";
>  > }
>  > but how will the Attach:filename.jpg work in pages of the 'Special'
>  > group?
>  > (The reason for two different file structures is, that some groups
>  > have per page subdirecories in order to have per page image galleries,
>  > and others shall not have per page subdirectories, as there will only
>  > be one image per page, but about a thousand pages....)
>  > Thanks for any hints!
>  >   ~Hans
>  _______________________________________________
>  pmwiki-users mailing list
>  pmwiki-users at pmichaud.com
>  http://www.pmichaud.com/mailman/listinfo/pmwiki-users

I've already been trapped there while designing
http://www.pmwiki.org/wiki/Cookbook/LinkedResourceExtras, and this led
me to the conclusion that we're hitting there a design flaw or more
truely an implementation choice dictated for simplicity. There's also
a bunch of PITS entries for this feature.

For now, the attachment handling is only designed to work on a
wiki-wide basis. Having it working per group or per page is a bit more

Anyway, there's always a mean to overcome the difficulty, by providing
a cookbook recipe overriding all the standard upload features with
your own. In this case here's my $0.02, hoping it could help you to
implement some kind of solution.

As I understand the requirements, the main difficulty would be to
handle the upload parameters (mainly the directory scheme but this
wouldn't be necessary the only one) as per page or per group
configuration datas which should be made accessible from other pages
in the wiki.

The (quasi-)immediate conclusion is to handle upload parameters as
Page/Group attributes in a more or less same spirit that the actual
page/group security stuff (btw, the upload directory scheme doesn't
need to rely on the page store configuration).

If you decide to go that way (ie. with a major rewrite of the core
upload script), would you please also consider the recipe writer
needs, providing utility functions to ease the handling of
attachements like LinkedResourceExtras does from recipe code.

As far as I am concerned, I could have a try at coding a proof of
concept recipe but since I wouldn't be able to handle this other than
as a background task, you should have to be (really) patient between
the releases...;)

Hope this helps,

More information about the pmwiki-users mailing list