[pmwiki-users] conditional for attachments

noskule noskule at gmx.net
Tue Nov 13 10:26:19 CST 2007


Patrick R. Michaud schrieb:
> On Tue, Nov 13, 2007 at 08:54:30AM -0600, Tegan Dowling wrote:
>> On Nov 13, 2007 8:42 AM, noskule <noskule at gmx.net> wrote:
>>> Patrick R. Michaud schrieb:
>>>> On Tue, Nov 13, 2007 at 02:44:45PM +0100, noskule wrote:
>>>>> hi list
>>>>> is there a way to find out if a attachment with a given name exists?
>>>>> That works the same way as exists for pages does?
>>>>>
>>>>> In the documentation I found only a way to find out it any attachemt exists.
>>>> We don't yet have a conditional for testing for specific attachments.
>>>> I could probably write one as a recipe, though.
>>> that would be cool, one thing that I stepped over was, that if user
>>> upload a profile portrait they will upload it in different formats like
>>> jpg, png, so the conditional should be able ot detect the filename
>>> without the extension. But if wildcards ar supported this will probably
>>> work anyway .. .
>>>
>>> (:if attachment {*$Group}/{*$Name}-Portrait.*:)
>>
>> FYI, there's a least one other person who would use this, if it
>> existed.  I'd use it on profile pages, as noskule does, and also on
>> some blog-like pages.
> 
> I wasn't planning on supporting wildcards in the conditional --
> would that be very important?
> 
> Also, do we really want to solve this with (:if ... :)
> conditionals, or would it be better to come up with an Attach:-like
> syntax that can automatically find the correct image?  E.g., so 
> someone could write 
> 
>   Attach:Profiles/Pm/image 
> 
> and have it automatically look for 'image.gif', 'image.jpg',
> and 'image.png' if 'image' doesn't exist.  (The administrator
> would be able to define the list of extensions to be searched.)

Yes, I thought on that to, this would be great for the example above or
in general, handling images.

> 
> That seems a lot nicer than
> 
>     (:if attachexists Profiles/Pm/image.png:)Attach:Profiles/Pm/image.png
>     (:elseif attachexists Profiles/Pm/image.jpg:)Attach:Profiles/Pm/image.jpg
>     (:elseif attachexists Profiles/Pm/image.gif:)Attach:Profiles/Pm/image.gif
>     (:if:)
> 
> OTOH, it's not clear what to do in the case where none of the
> images exist -- we don't want to create an upload link for 'image'
> without an extension.
> 
> Pm

like tegan says, The admin could specify an customized "else" operation.
This could be simply "nothing" or "please upload XY".

There would be other cases for example pages where I need a certain file
like status-report.doc. So I could build a pagelist where all pages are
listed and show on which pages the status-report is already uploades and
on which not.

So I think the if-version is much more flexible for the admin and
usefull for other file-types / cases
grz nos

> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
> 




More information about the pmwiki-users mailing list