Pdf 出口汇流问题

Pdf 出口汇流问题,pdf,macros,export,confluence,Pdf,Macros,Export,Confluence,我们已经创建了一个自定义用户宏,该宏创建了一个包含子页面的表,该表还填充了诸如上次更新、版本、更新人等信息 导出页面时,填充表格,但导出空间时,表格为空 代码如下 ## Macro title: Page Data ## Macro has a body: N ## Body processing: n/a ## Output: HTML ## ## Developed by: Brian Mitchell ## Date created: 06/27/2013 ## @noparams #s

我们已经创建了一个自定义用户宏,该宏创建了一个包含子页面的表,该表还填充了诸如上次更新、版本、更新人等信息

导出页面时,填充表格,但导出空间时,表格为空

代码如下

## Macro title: Page Data
## Macro has a body: N
## Body processing: n/a
## Output: HTML
##
## Developed by: Brian Mitchell
## Date created: 06/27/2013
## @noparams

#set ($PageTitle = $content.displayTitle)
#set ($PageVersion = $content.version)
#set ($PageDate = $action.dateFormatter.formatGivenString("dd MMM yyyy",    $content.lastModificationDate))
#set ($PageAuthor = $content.lastModifierName)
#set ($pageListArray = [])
#set ($currentPage = $action.page)
#set ($spaceHome = $space.getHomePage())

#macro ( process $rp )
 #set ($pagelist = $rp.getSortedChildren() )  ## returns List<Page>
   #foreach( $child in $pagelist )
     #set($p = $pageListArray.add( $child ) )
       #if( $child.hasChildren() )
          #process ( $child )
    #end
 #end
#end

    #process ($currentPage)


    <h1> Confluence Page Versions </h1>
    <table class="confluenceTable">
    <tbody>
   <tr>
    <th class="confluenceTh">Page Title</th>
    <th class="confluenceTh">Page Version</th>
     <th class="confluenceTh">Date</th>
     <th class="confluenceTh">Changed By</th>
    </tr>

    <tr>
    <td>$PageTitle</td>
     <td><a href=http://confluence.mango.local/pages/viewpreviousversions.action?pageId=$content.getIdAsString()>$PageVersion</a></td>
      <td>$PageDate</td>
     <td>$PageAuthor</td>
     </tr>


      #foreach( $child in $pageListArray)   ## child is of type Page
        <tr>
      <td class="confluenceTd">$child.getTitle()</td>
        <td class="confluenceTd"><a href=http://confluence.mango.local/pages/viewpreviousversions.action?pageId=$child.getIdAsString()>$child.getVersion()</a> </td>
        <td class="confluenceTd">$action.dateFormatter.formatGivenString("dd MMM yyyy", $child.getLastModificationDate())</td>
          <td class="confluenceTd">$child.getLastModifierName()</td>
  </tr>
            #end

         </tbody>
        </table>
然而,当我编辑代码以将空间的全部内容放入数组中时,表在导出时填充

所以我换了 处理$currentPage 具有 处理$spaceHome

所以我认为问题出在空间导出上,下面的命令不起作用 设置$currentPage=$action.page

有人知道我可以用什么来代替吗?

$action Velocity变量指的是当前正在执行的操作。在执行空间导出时,$action指的是导出空间操作而不是导出页面操作,并且由于导出空间操作没有可从操作对象获得的页面变量,因此,$action.Page不会返回任何内容

但是,您很幸运:导出空间功能确实传递了当前正在导出的页面的上下文,并且您已经在使用它了$content指的是要导出的ContentEntityObject,它实际上与您试图从$action.page获取的内容相同

要修复您的示例,只需将对process宏的调用调整为使用$content即可。在Confluence 5.5上导出整个空间时,以下内容适用于我:

## Macro title: Page Data
## Macro has a body: N
## Body processing: n/a
## Output: HTML
##
## Developed by: Brian Mitchell
## Date created: 06/27/2013
## @noparams

#set ($PageTitle = $content.displayTitle)
#set ($PageVersion = $content.version)
#set ($PageDate = $action.dateFormatter.formatGivenString("dd MMM yyyy",    $content.lastModificationDate))
#set ($PageAuthor = $content.lastModifierName)
#set ($pageListArray = [])
## #set ($currentPage = $action.page)
#set ($spaceHome = $space.getHomePage())

#macro ( process $rp )
 #set ($pagelist = $rp.getSortedChildren() )  ## returns List<Page>
   #foreach( $child in $pagelist )
     #set($p = $pageListArray.add( $child ) )
       #if( $child.hasChildren() )
          #process ( $child )
    #end
 #end
#end

    #process ($content)


    <h1> Confluence Page Versions </h1>
    <table class="confluenceTable">
    <tbody>
   <tr>
    <th class="confluenceTh">Page Title</th>
    <th class="confluenceTh">Page Version</th>
     <th class="confluenceTh">Date</th>
     <th class="confluenceTh">Changed By</th>
    </tr>

    <tr>
    <td>$PageTitle</td>
     <td><a href=http://confluence.mango.local/pages/viewpreviousversions.action?pageId=$content.getIdAsString()>$PageVersion</a></td>
      <td>$PageDate</td>
     <td>$PageAuthor</td>
     </tr>


      #foreach( $child in $pageListArray)   ## child is of type Page
        <tr>
      <td class="confluenceTd">$child.getTitle()</td>
        <td class="confluenceTd"><a href=http://confluence.mango.local/pages/viewpreviousversions.action?pageId=$child.getIdAsString()>$child.getVersion()</a> </td>
        <td class="confluenceTd">$action.dateFormatter.formatGivenString("dd MMM yyyy", $child.getLastModificationDate())</td>
          <td class="confluenceTd">$child.getLastModifierName()</td>
  </tr>
            #end

         </tbody>
        </table>

是的,问题是在查看页面之前,没有为宏定义$currentPage变量。您在多少页上使用宏?这不是一个很好的解决方案,但您可以为每个页面创建一个唯一的宏,并更具体地定义页面。这将在多个空间中使用,因此我认为这不是一个合适的解决方案。如果页面没有已加载。祝你好运