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

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads