I am trying to create a user macro similar to content by label with a few changes in the markup along with adding pagination. But I do not know what I should be setting the contents variable to, I cannot seem to figure out how to return the results on the page.
This the code I have, What do I need to set the contents variable to and what is the syntax for doing this?
#* @vtlvariable name="contents" type="java.util.List<com.atlassian.confluence.core.ContentEntityObject>" *#
#* @vtlvariable name="excerpter" type="com.atlassian.confluence.plugins.macros.advanced.xhtml.AdvancedMacrosExcerpter" *#
#* @vtlvariable name="excerptType" type="com.atlassian.confluence.plugins.macros.advanced.xhtml.ExcerptType" *#
#* @vtlvariable name="i18n" type="com.atlassian.confluence.util.i18n.I18NBean" *#
#* @vtlvariable name="limitLabelLinksToSpace" type="boolean" *#
#* @vtlvariable name="req" type="javax.servlet.http.HttpServletRequest" *#
#* @vtlvariable name="showLabels" type="boolean" *#
#* @vtlvariable name="showSpace" type="boolean" *#
#* @vtlvariable name="staticResourceUrlPrefix" type="java.lang.String" *#
#* @vtlvariable name="title" type="java.lang.String" *#
#* @vtlvariable name="stringUtils" type="org.apache.commons.lang.StringUtils" *#
## @Param labels:title=Label|type=confluence-content|required=true
## @Param sort:title=Sort By|type=enum|enumValues=title, creation, modified|required=true
## @Param reverse:title=Reverse Sort|type=boolean|desc="Used only in conjunction with the 'Sort By parameter."
## @Param limitLabelLinksToSpace:title=Maximum Number of Pages|type=string|default=15
## @Param title:title=List Title|type=string|default=Stories by label
## @Param showLabels:title=Show Labels for Each Page|type=boolean|default=false
## @Param showSpace:title=Show Space Name for Each Page|type=boolean|default=false
## @Param excerpt:title=Excerpt Display|type=enum|enumValues=none, simple, rich content|required true|desc=How to display excerpts for each page.
## @Param showpageribbon:title=Show Page Ribbon|type=boolean|default=true
## $helper.renderConfluenceMacro("{next_previous_links:WrapAtEnd=false}")
## $helper.renderConfluenceMacro())
#if ($paramtitle)
<h3>$paramtitle</h3>
#end
#if ($contents.length() > 0)
<ul class="content-by-label">
#foreach ($content in $contents)
<li>
<div>
#contentIconWithLinkPrefix($content $staticResourceUrlPrefix)
</div>
<div class="details">
#contentHrefWithLinkPrefix($content $req.contextPath)
#if ($paramshowSpace) #contentOther($content) #end
#set ($excerptHtml = $excerpter.createExcerpt($content, $paramexcerptType) )
#if ($stringUtils.isNotBlank($excerptHtml))
<span class="smalltext"> $excerptHtml</span>
<div> this is a test</div>
#end
#if ($paramshowLabels)
<div class="label-details">
#if( $paramlimitLabelLinksToSpace )
#set( $spaceKey = $content.getSpaceKey() )
#else
#set( $spaceKey = "" )
#end
#set ($paramlabels = $content.getVisibleLabels($action.authenticatedUser))
#parse("/com/atlassian/confluence/plugins/labels/components/labels-list.vm")
</div>
#end
</div>
</li>
#end
#if ($paramshowpageribbon)
<div style="text-align:center; font-size: 14px;">
#if($pager.hasPrev)
<a href="$pager.prevLink">«</a>
#end
#foreach ($page in $pager.pages)
<a href="$page.link" class="#if($page.current) current #end">
$page.number
</a>
#end
#if($pager.hasNext)
<a href="$pager.nextLink">»</a>
#end
</div>
</ul>
#end
#else
<div class="content-by-label macro-blank-experience">
<strong class="content-label-header">$i18n.getText('contentbylabel.emptymacro.label')</strong>
<p>$i18n.getText('contentbylabel.emptymacro.content')</p>
</div>
#end
Hello there Karina!
Some time ago another customer had the same need and came up with this thread, maybe it could help you out as well!!
Let us know!
Thank you, but before I can even resolve the pagination issue, I have to have the content returned. I am able to input the parameters of the macro, but I cannot get any content to be returned, I seem to be missing something in the code to return the content I want. I guess I do not know what the $contents variable needs to be set to, or what helpers I need if any.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.