我们目前正在Dynamics 365 Portal上安装博客。想要修改帖子的布局,我们根据这个结构重新创建了一个模板: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:如果你有一个解决方案来检索n:n关系实体而没有fetchXml查询我很满意。
我不认为你的FetchXML是正确的。如果您使用“高级查找”来创建FetchXML,则非常直接。以下是帐户引导的示例,请注意多对多交叉表中的其他链接实体。
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="account">
<attribute name="name" />
<link-entity name="accountleads" from="leadid" to="accountid" visible="false" intersect="true">
<link-entity name="lead" from="leadid" to="accountid" alias="ac">
<filter type="and">
<condition attribute="leadid" operator="eq" uiname="Test Lead" uitype="lead" value="{FC271420-B2BB-4A87-B852-1DF7CF4B4F3E}" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>