Feature Proposal: Suggested Enhancement to WEB Variable

Motivation

The WEB variable does not work as expected in subwebs. Instead of showing the name of the current (sub)web, it shows the full path back up to the topmost parent web. There needs to be a simple way to show just the name of the current web, without resorting to a plugin.

Description and Documentation

Apparently, a new feature has recently been added in TWiki that allows for specifying %WEB{format=current}% to just get the current webname (last element of the path). This would be handy to keep Foswiki in sync with TWiki.

TWikiScreenshot.png

However, this is a lot to type and not very flexible. What if I want to see, e.g., two levels? Or three? (Use case: Our home wiki has many levels of subwebs, e.g. http://wiki.cfcl.com/Projects/Access/Utiles/DS is a subweb)

Suggestion:
Parameter: Description: Default:
number
a number from 1 to the number of webs in the path
"$web"

A number that is larger than the maximum actual number of webs in the path would simply return the same value that %WEB% returns now.

Examples

Assuming %WEB% is Engineering/TechPubs/Apps:
%WEB{1}% returns: Apps ; %WEB{2}% returns: TechPubs/Apps, etc.

Impact

No backward compatibility issues.

%WHATDOESITAFFECT%
edit

Implementation

-- Contributors: VickiBrown - 14 Feb 2016

Discussion

Have a look at WebLinkPlugin.

-- MichaelDaum - 15 Feb 2016

We can't change what %WEB% returns, and the format parameter that TWiki added is truly, deeply, horrible. Instead of that, I'd favour a %CURWEB% (pick a better name) variable that provides what you want. It's cleaner, simpler to implement, and I'm really not bothered about staying in stync.

-- Main.CrawfordCurrie - 17 Feb 2016 - 09:40

 
Topic revision: r3 - 17 Feb 2016, 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