You are here: Foswiki>Tasks Web>Item844 (20 Jun 2015, CrawfordCurrie)Edit Attach

Item844: can we make an 'issection' if operator

pencil
Priority: Enhancement
Current State: Proposal Required
Released In: n/a
Target Release:
Applies To: Engine
Component: INCLUDE
Branches:
Reported By: SvenDowideit
Waiting For:
Last Change By: CrawfordCurrie
I think we need an issection test for IF's as the way to INCLUDE some other section if the requested section isn't there is awful

also means we need a SECTION and section value.

%INCLUDE{
      "%IF{"'%INCLUDE{"%WIDGETSTOPIC%" section="footer-widgets" warn="off" pattern=".*([a-zA-Z]).*"}%' ~ ''"
         else="%WIDGETSTOPIC%"
         then="%SYSTEMWEB%.DefaultWidgets"
      }%"
      section="footer-widgets" 
      warn="on"
      WIDGETSTOPIC="%WIDGETSTOPIC%"
}%

compared to the proposed

%INCLUDE{
      "%IF{"issection %WIDGETSTOPIC%/(section.name='footer-widgets')"
         else="%WIDGETSTOPIC%"
         then="%SYSTEMWEB%.DefaultWidgets"
      }%"
      section="footer-widgets" 
      warn="on"
      WIDGETSTOPIC="%WIDGETSTOPIC%"
}%


Two thoughs. (1) Is %TMPL:INCLUDE and option? (2) How about %INCLUDE{"topic1 || topic2 || topic3" ...}% to include either topic1, topic2 or topic3 depending on which is found first in the given prio. That way I could get rid of %WEBCOMPONENT{}% in NatSkin as well, which basically implements what you intend to do in the examples above although not down to section level.

-- MichaelDaum - 23 Jan 2009

If I understand it correctly, you want a "hassection" operator? As in, "does this topic contain this section"?

Sounds like a pretty specialised requirement to me......

-- CrawfordCurrie - 23 Jan 2009

its only specialised because it doesn't exist. Its actually a pretty useful thing for making it trivial for users to over-ride built in functions.

Micha - I like the INCLUDE{"topic1 || topic2 || topic3" ...} idea - but would like to be able to express "topic1/section[wqer] || topic2/section[ewwww] || topic3/section[other]" ... as well..

-- SvenDowideit - 23 Jan 2009

I understand the requirement. I meant it's specialised because it's like a "one off" for a content-access operation. Asking the question "does this section exist" is not a million miles from "get me this section" - and indeed, you have partially invented such a syntax in your examples above. I think what you are really trying to say is something like this:

%INCLUDE{
      "%IF{"exists %WIDGETSTOPIC%/sections[name='footer-widgets']"
         else="%WIDGETSTOPIC%"
         then="%SYSTEMWEB%.DefaultWidgets"
      }%"
      section="footer-widgets" 
      warn="on"
      WIDGETSTOPIC="%WIDGETSTOPIC%"
}%

-- CrawfordCurrie - 23 Jan 2009

I really would like to see more xpath, e.g. %INCLUDE{"topic[expr]/section[expr]"}%

-- MichaelDaum - 23 Jan 2009

Fascinating, Crawford independently identified %WIDGETSTOPIC%/sections[name='footer-widgets'] as plausible syntax, and Foswiki::Address resourcetypes also supports this address notation: 'Web/SubWeb.Topic'/SECTION[name='something']

-- PaulHarvey - 22 Feb 2012

Enhancement requires a specific proposal. Main.Jankrueger, this may also be relevant to your problem on IRC from 19/6/15

-- Main.CrawfordCurrie - 20 Jun 2015 - 07:56

ItemTemplate edit

Summary can we make an 'issection' if operator
ReportedBy SvenDowideit
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component INCLUDE
Priority Enhancement
CurrentState Proposal Required
WaitingFor
Checkins
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release01x01Checkins
Topic revision: r10 - 20 Jun 2015, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy