Tags:
create new tag
, view all tags

Question

I need syntax help with TWiki 4.0.4.

My upgraded site is at http://pj.freefaculty.org/ps110 and it runs pretty well. I'm having some trouble updating the skin to serve the same purpose as the TWiki 2004 edition.

I want to show some parts only to registered & logged in users. I was experimenting with the context authenticated syntax, but it fails. In the template file "view.pattern.tmpl" now there is this:

%TMPL:INCLUDE{"viewtopicactionbuttons"}%

And I try things like this, but they fail and wreck the TWiki display.

%IF{"context authenticated" then="%TMPL:INCLUDE{"viewtopicactionbuttons"}%"}%

How about helping me out?

Please?

Environment

TWiki version: TWikiRelease04x00x04
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Debian
Web server: Apache
Perl version:  
Client OS: Linux
Web Browser: Firefox
Categories: Skin

-- PaulJohnson - 01 Sep 2006

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

Paul, remember that TWiki language is a macro language, not a programming language. Further, it is evaluated in two steps; first, %TMPL macros are evaluated, and only when they have been fully expanded are other macros (like %IF) expanded. So in the above example, the TMPL:INCLUDE is already fully expanded before %IF can get its teeth into it.

Putting aside the pros and cons of this double expansion, the TMPL macros include some limited support for what you are trying to do. Specifically, the %TMPL:P macro supports a "context" parameter to perform this sort of test. However it is not easy to use, has limited support for tests, and I will steer you away from it. A simpler approach is to use %INCLUDE rather than %TMPL:INCLUDE, thus:

%INCLUDE{%IF{"context authenticated" then="ViewTopicActionButtons" else="NotAuthenticated"}%" warn="off"}%
The expansion order is inside-out, left-to-right, so the embedded %IF gets expanded before the %INCLUDE. ViewTopicActionButtons is a topic. The warn="off" stops %INCLUDE complaining about a missing topic (e.g. if NotAuthenticated doesn't exist).

-- CrawfordCurrie - 02 Sep 2006

 
Change status to:
Topic revision: r2 - 2006-09-02 - CrawfordCurrie
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.