Quantcast
Channel: XWiki Forum - Latest topics
Viewing all articles
Browse latest Browse all 1537

Possible to use multi value macro parameters?

$
0
0

I’m trying to improve the Show Children by Tag macro by allowing for entering multiple tags as a paramater.

Is it possible to enable multiple entries in a macro parameter?

If so, I believe something like the below might work; thoughts?

  ## Get the current page reference
  #set ($tags = $wikimacro.parameters.tag)
  ## Get the children pages of the current page
  #set ($childrenPages = $doc.getChildren())
  #if ($wikimacro.parameters.Sort)
    #set ($childrenPages=$sorttool.sort($childrenPages))
  #end 
  ## Iterate over the children pages
  #foreach ($childRef in $childrenPages)
    ## Get the tags of the child page
    #set ($childTags=$xwiki.tag.getTagsFromDocument($childRef))
    ## Check if the child page has the given tag
    #set ($match = false)
    #foreach ($tag in $tags)
      #if ($childTags.contains($tag))
        #set ($match = true)
      #end
    #end
    #if ($match)
      ## Display a link to the child page
      * [[$childRef]]
    #end
  #end

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1537

Trending Articles