Tags:
create new tag
view all tags

Question

I'm creating some templates for pages that will probably have movie files attached - but not always.

I'd like to include an embed tag automatically on these pages, but only if the movie file is attached.

To make this easier, the movie files will always be named the same thing.

Is there any TWiki function for checking existing attachments? Something I can put in an %IF or calc IF()?

I see calc EXISTS(), but it appears to be for topics, not attachments.

Any guidance would be appreciated!

Environment

TWiki version: TWikiRelease04x00x05
TWiki plugins: Defaults with bsae install
Server OS: FreeBSD 6.1-RELEASE
Web server: Apache 2.2
Perl version: 5.8.5
Client OS: n/a
Web Browser: Firefox 2
Categories: Missing functionality

-- MahlonSmith - 11 Jan 2007

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

We do not yet have a good ContentAccessSyntax to query meta data easily. I see two ways to work around this:

1. Create a simple plugin (if you know Perl) to expand a custom variable, such as %ATTACHMENTEXIST{name}%. See TWikiPlugins.

2. Use SEARCH to test for an attachment. Do a FormattedSearch to test if an attachment exist. You can search all meta data with a VarSEARCH, but you can't format the result.

The meta data of an attachment looks like this: (hint: do a topic view with a view=debug parameter)

%META:FILEATTACHMENT{name="FooBar.mpg" attachment="FooBar.mpg" attr="" comment="Blah" date="1166511779" path="FooBar.mpg" size="50918" user="Main.PeterThoeny" version="2"}%

So you can SEARCH for it, and format a desired output. If there is no hit, search returns nothing. Untested search:

%SEARCH{ "META\:FILEATTACHMENT\{name\=\"FooBar.mpg\"" topic="%TOPIC%" type="regex" nonoise="on" format="FooBar.mpg found" }%

-- PeterThoeny - 11 Jan 2007

The SEARCH works great for my need - thanks so much!

-- MahlonSmith - 11 Jan 2007

Glad it worked out.

-- PeterThoeny - 11 Jan 2007

Change status to:
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2007-01-11 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.