Tags:
create new tag
view all tags

Question

I am developing a skin that INCLUDEs another topic as the sidebar. I would like it to first check the current web to see if the topic exists, and then check the TWiki web to see if it exists there. Doing this will allow individual web authors to overload the left bar. Is this possible?

I looked into how the PatternSkin does this, and it seems to just include the topic from the current web. It ensures that the topic exists in the current web by automatically creating the topic with a default layout when a new web is created. If this is the route I have to take, how can I achieve this?

Environment

TWiki version: TWikiRelease04x00x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Skin

-- KevinCraft - 31 Mar 2006

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.

looking at the docco for INCLUDE I think you should be able to do

%INCLUDE{"TheMaybeTopic" warn="%INCLUDE{\"TWiki.TheDefaultTopic\"}%"}%

though my testing suggests that the warning has a limited length - so you might need to play with it a bit

-- SvenDowideit - 07 Apr 2006

You can also use the SpreadSheetPlugin to check for the existence of a topic, and based on this include one or the other topic. Untested example:

%CALC{"$IF($EXISTS(TopicOne), $NOP(%)INCLUDE{TopicOne}$NOP(%), $NOP(%)INCLUDE{TopicTwo}$NOP(%))"}%

-- PeterThoeny - 07 Apr 2006

EXIST should be EXISTS (-:

I was attempting to use %IF{...}% in conjunction with %CALC($EXISTS(...)}%. An interesting thing happened with the following:

  • Set AVAR = %CALC{$EXIST(%WEB%.LocalIncludes)}%

Evaluating the result in %AVAR% the statement:

%IF{" $ AVAR='1'" then="dostuff"}%

-- or --

%IF{" $ AVAR='0'" then="dostuff"}%

-- fail, while --

%IF{"defined AVAR" then="dostuff"}%

works. Apparently, the %CALC{..}% is a numeric value(?).. I dunno - I tried to coerce it by prefixing with alpha (e.g., Set AVAR = A%CALC{$EXIST(%WEB%.LocalIncludes)}%), but no go.

The solution above by Peter is very doable.. Thanks!

I gotta register! (dave mansfield)

-- TWikiGuest - 02 Nov 2006

In SVN there is a plugin called FallBackPlugin that does exactly what you're asking for. I know because I proposed the use case and MeredithLesly implemented it but never published it on TWiki.org. I have tested it and it works as advertized.

-- LynnwoodBrown - 03 Nov 2006

I'm having similar problems with DynamicDoubleBracketLink

-- KeithHelfrich - 15 Jul 2007

The SpreadSheetPlugin as a bug where you need to specify a full web.topic qualifier in the $EXISTS() function. Specify the web. prefix, or upgrade to the latest SpreadSheetPlugin.

-- PeterThoeny - 15 Jul 2007

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2007-07-15 - 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.