节点链接不工作



我想将我的结果从searchfn链接到页面,而不仅仅是组件。 目前我有:

[#if queryStr?has_content]
[#assign searchResults = mySearchfn.searchContent('website', queryStr, '/home', 'mgnl:component') /]
[#assign recordsFound = searchResults?size /]
<h3>  <em>${recordsFound}</em> Results -> "${queryStr}"</span></h3>
<div class="list-group">
[#if searchResults?has_content]
[#list searchResults as item]
<a href="${cmsfn.link(item)}" class="list-group-item">
<p class="list-group-item-text">${item.excerpt!}</p>
</a>

<p class="list-group-item-text">${item.page!}</p>
<!--return:getPath() of the node (pointing to component) as String-->
<p class="list-group-item-text">${item.pageLink!}</p>
<!--return:path/to/page as String-->
[/#list]
[/#if]
</div>
[/#if]

我从标签中得到的网址类似于"路径/到/页面/区域/组件",问题是我看不到整个页面,只能看到组件。

<a href="${cmsfn.contentByPath(item.pageLink, "website")}">link</a>

给定上面的示例,仅将 URL 构建为/page 而不是使用完整字符串(路径/到/页面(构建

  • 改用searchPages(String query, String startPath)
  • 将代码中的最后一个参数更改为mgnl:page而不是mgnl:component(因为最后一个参数是返回类型而不是搜索类型(。

你可以试试:

${cmsfn.link(cmsfn.page(item((}

或:

${cmsfn.link(cmsfn.contentByPath(item.pageLink((}

最新更新