You are here: Foswiki>Tasks Web>Item14360 (31 Jan 2018, GeorgeClark)Edit Attach

Item14360: Add VarPARENTTOPIC

pencil
Priority: Enhancement
Current State: Waiting for Release
Released In: 2.2.0
Target Release: minor
Applies To: Engine
Component: FoswikiUsability
Branches: master Item14288 Item14380 Item14537
Reported By: VickiBrown
Waiting For:
Last Change By: GeorgeClark
Please add the extremely useful PARENTTOPIC variable.

See TWiki for details.

PARENTTOPIC -- parent of current topic

  • Syntax: %PARENTTOPIC% or %PARENTTOPIC{ format="..." topic="..." }%
  • Expands to: %PARENTTOPIC%, renders as %PARENTTOPIC%
  • Parameters:
    Item Description Default
    format="..." Format string used to display parent topic, where $web expands to the web name, and $topic expands to the topic name. Additional formatting tokens can be used. "$topic"
    (topic name)
    topic="..." Get parent of "Topic" or "Web.Topic" "%WEB%.%TOPIC%"
    (current topic)

-- VickiBrown - 29 Mar 2017

Seems reasonable. I'll mark this as confirmed as an enhancement. Note that this is just a shorthand for using the =%META{"parent"}% macro.

%META{"parent" topic="Sandbox.TestParentMacro" format="$web.$topic" depth="1"}% returns IPv6Link

-- GeorgeClark - 29 Mar 2017

META is deprecated. Here's another way:

%QUERY{"'Sandbox.TestParentMacro'/parent.name"}% returns IPv6Link

This simplifies down to %QUERY{"parent.name"}% to get the current topics parent:

-- GeorgeClark - 30 Mar 2017

Wouldn't it be more useful when this macro iterated up the parent relation to the root?

-- MichaelDaum - 30 Mar 2017

I think %PARENTTOPIC{"name"}% is more memorable than %QUERY{"parent.name"}% smile

Michael - are you thinking of an attribute that would ask for the full path? That would be cool.

-- VickiBrown - 30 Mar 2017

The META macro essentially does a "foreach" up the parent hierarchy, rendering the format with a separator at each level See System.VarMETA#A_61_34parent_34_61

I think that the implementation should be PARENTTOPIC is equivalent to META{"parent"} with defaults to only show the $web.$topic of the immediate parent. The remaining meta parameters would be available to make it recurse the parent path with whatever separator desired. So a superset of the TWiki PARENTTOPIC macro, but with the same default behaviour.

-- GeorgeClark - 30 Mar 2017

This is implemented in master - See https://trunk.foswiki.org/System/VarPARENTTOPIC

-- GeorgeClark - 03 Apr 2017
 
Topic revision: r10 - 31 Jan 2018, GeorgeClark - This page was cached on 26 Jan 2021 - 18:12.

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