我们目前正在 Dynamics 365 门户上安装博客。想要修改帖子的布局,我们基于此结构重新创建了一个模板:https ://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/liquid-templates/objects/blogs/
因为 adx “post” 对象不包含标签,所以我们必须使用 fetchxml 查询来获取它们。
问题是查询检索所有标签: 只有Général标签应该只显示在第一个帖子上。
完整代码:
{% assign blog = blogs['Actualités et annonces'] %}
{% assign posts = blog.posts %}
<div class="col-md-8">
<div class="content-panel panel panel-default">
<div class="panel-heading">
{% assign sitemarker = sitemarkers["Blog Home"] %}
{% assign snippet = snippets["Home Blog Activity Heading"] %}
<a class="pull-right" href="{{sitemarker.url}}"> All Blogs </a>
<h4>
<a class="feed-icon fa fa-rss-square" href="{{ blogs.feedpath }}">
{{ snippet.adx_value }}
</a><div class="grid-container">
{% for post in posts.all %}
<div class="grid-item">
<a class="image-header" href="{{ post.url }}">
{% if post.new_category %}
{% assign category = entities.new_vignette[post.new_category.id] %}
{% assign imgpath = category.new_path %}
{% elsif post.new_vignette %}
{% assign imgpath = post.new_vignette %}
{% else %}
{% assign imgpath = "../pocfabien/avarap-entete" %}
{% endif %}
<img class="img-responsive img-post" src="{{imgpath}}">
</a>
<div class="content-header">
<h4 class="list-group-item-heading">
<a href="{{ post.url }}">{{ post.title }}</a>
</h4>
<br />
<abbr>{{ post.publish_date }}</abbr>
</div>
<div class="content-preview">
{{post.adx_summary}}
</div>
<div>
{% fetchxml tags %}
<fetch>
<entity name="adx_tag">
<attribute name="adx_name" />
<attribute name="adx_tagid" />
<link-entity name="adx_blogpost_tag" from="adx_tagid" to="adx_tagid" intersect="true">
<filter>
<condition attribute="adx_blogpostid" operator="eq" value="{{ post.adx_blogpostid }}" />
</filter>
</link-entity>
</entity>
</fetch>
{% endfetchxml %}
{% for tag in tags.results.entities %}
{{ tag.adx_name }}
{% unless forloop.last %} | {% endunless %}
{% endfor %}
</div>
<img class="plusign" src="plusign.png">
</div>
{% endfor %}
</div>
</h4>
</div>
</div>
</div>
PS:如果您有一个无需 fetchXml 查询即可检索 n:n 关系实体的解决方案,我会全力以赴。